3

I'm using rvest and read_html to try and scrape a site. The scraping has worked for me before, but it won't work anymore. Using R version 3.4.2 and rvest 0.3.2

This is my code:

library(rvest)

read_html("http://hamilton.edu/news/story/the-medias-effect-on-womens-body-image")

and my error is:

Error in read_connection_(x, n) : 
  Evaluation error: Failure when receiving data from the peer.

Any ideas?

3
  • I cannot reproduce your error, it may be version specific or network related Nov 27, 2017 at 2:24
  • Yeah, I'm not sure. I'm using R version 3.4.2 and rvest version 0.3.2. I'll add that in the description
    – Evan O.
    Nov 27, 2017 at 2:30
  • Those versions are current and what I'm using as well. That would suggest it is more network related, such as a proxy as hrbrmstr suggested Nov 27, 2017 at 2:49

1 Answer 1

9

Wrapping the URL in url() seems to do the trick.

read_html(url("http://hamilton.edu/news/story/the-medias-effect-on-womens-body-image"))
3
  • You wouldn't be behind a proxy server, would you? The fact that a connection object works but not a direct URL (which would use httr/curl under the covers) is making me think the proxy had something to do with this.
    – hrbrmstr
    Nov 27, 2017 at 2:31
  • How would I find out if I'm behind a proxy server? I'm not too savvy with that stuff
    – Evan O.
    Nov 27, 2017 at 2:35
  • If using Windows, then you'd generally see it in Internet Explorer's settings unless your network uses a transparent proxy in which case it'll be more difficult to detect.
    – hrbrmstr
    Nov 27, 2017 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.