| page_text | R Documentation |
page_text() decodes the body to a UTF-8 string, page_json() parses it
with jsonlite::fromJSON(), and page_html() with xml2::read_html().
page_text(resp, encoding = NULL, check = TRUE)
page_json(resp, ..., check = TRUE)
page_html(resp, encoding = NULL, check = TRUE)
resp |
A response from |
encoding |
The body's charset, overriding the response's. |
check |
Whether an HTTP status outside 200–299 is an error. |
... |
Passed on to |
The charset comes from the response's content-type; without one,
page_text() and page_json() assume UTF-8 and page_html() leaves it
to the page's own <meta charset>. ISO-8859-1 is read as windows-1252, as
browsers do. A body that is not valid in its charset is an error. A "not
found" page served with status 200 passes the status check; page_json()
refuses an HTML body, and for a page, compare resp$url with the URL
asked for.
page_text(): a UTF-8 string. page_json(): what
jsonlite::fromJSON() returns. page_html(): an xml_document whose
relative links resolve against resp$url. Errors are classed under
safeconduct_error: safeconduct_http_error for a status outside
200–299, carrying status and url, and safeconduct_parse_error for
a body that cannot be decoded, or HTML where JSON was asked for.
## Not run:
page_json("https://results.vancouver.ca/data/arearesults.json")
page_html("https://www12.statcan.gc.ca/census-recensement/index-eng.cfm")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.