Comments (4)
Hmmm, that's a weird one - I can't even figure out what the encoding is supposed to be.
from rvest.
It's cp1251
. I have another example: http://psytests.org/.
from rvest.
A few more diagnostics:
library("httr")
library("rvest")
url <- "http://psytests.org"
# No encoding in http request
r <- GET(url)
headers(r)$`Content-Type`
# So default text content from httr is bad
content(r, "text")
# stringi thinks encoding is ISO-8859-1
as.data.frame(stringi::stri_enc_detect(content(r, "raw"))[[1]])
# But it's not
stringi::stri_encode(content(r, "raw"), "ISO-8859-1")
# It's actually cp1251
stringi::stri_encode(content(r, "raw"), "cp1251")
# Which also works when we give it to content
content(r, "text", encoding = "cp1251")
# But not when we give it to rvest::html
rvest::html("http://psytests.org", encoding = "cp1251")
from rvest.
rvest::html("http://psytests.org", encoding = "cp1251")
Translates to
rvest:::html.response(httr::GET("http://psytests.org"), encoding = "cp1251")
In rvest:::html.response
we can see that text <- httr::content(x, "text")
called without encoding
arg. Then XML::htmlParse
applied on the broken string.
from rvest.
Related Issues (20)
- Apparent typo in `read_html_live()` docs
- Github Actions Can't Install Dev Version HOT 4
- Figure out dynamic html elements selection
- read_html_live() practical implementation HOT 1
- Release rvest 1.0.4
- Long lines truncated at 10,000,000 chars. HOT 4
- Invalid Char in Json Text
- `req_perform_iteratively()` + `paths` HOT 1
- Need absolute URL helper HOT 1
- Web scraping vignette
- LiveHTML object corrupted after `$click()` HOT 1
- read_html should take httr2 response directly
- Hide more automated browser tells
- read_html_live() memory "leak" HOT 4
- Example broken in LiveHTML page HOT 1
- README should end with link to getting started vignette
- Select option from list using htmlLIVE
- Finding elements/nodes in regex way
- Try S7
- Use base pipe in examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rvest.