-1

I'm trying to scrape the following webpage in R using the XML, RCurl, or httr libraries: http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB

The webpage opens correctly in my browser. Here are my attempts to scrape the webpage:

library("XML")

#this works fine (QB projections) 
qb <- readHTMLTable("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/", header=1)$fantasy_table

#this does not (RB projections) 
rb <- readHTMLTable("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB", header=1)$fantasy_table

library("RCurl")
htmlParse("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB")

library("httr")
GET("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB")

I receive the following error with readHTMLTable and htmlParse: "Error: failed to load HTTP resource". With GET, I receive a status code 404, which suggests that the resource could not be found and that there may be a mistake in the way I'm sending the request. Given that I can open the webpage in my browser, I'm not sure what the problem is. Maybe it's a different kind of file than the functions are expecting? Any ideas?

Ideally, the scrape would be for all 146 entries (not just the first 25).

itpetersen
  • 1,475
  • 3
  • 13
  • 32

1 Answers1

1

Works fine for me with RCurl

require(RCurl)
readHTMLTable(getURL("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB"), header = 1)
> head(readHTMLTable(getURL("http://accuscore.com/fantasy-sports/nfl-fantasy-sports/Rest-of-Season-RB"), header = 1)$fantasy)
              V1  V2   V3   V4  V5   V6   V7  V8 V9  V10  V11
1 DeMarco Murray DAL 20.3 17.3 106 6.13 0.85 5.4 39 0.19  0.2
2 Jamaal Charles  KC 18.5 18.4  70  3.8  0.4 6.7 59  0.6 0.23
3   LeSean McCoy PHI 17.8 22.2 102 4.59 0.81 2.7 24 0.13 0.22
4   Le'Veon Bell PIT 17.1 25.1  95 3.78 0.65 3.5 30  0.2 0.26
5 Danny Woodhead  SD 16.6  9.5  47 4.95 0.27 5.7 60 0.76 0.14
6 Marshawn Lynch SEA 15.8 18.6  79 4.25 0.85 3.1 24 0.12 0.19
jdharrison
  • 30,085
  • 4
  • 77
  • 89
  • can u help in this question http://stackoverflow.com/questions/31423931/extract-data-from-raw-html-in-r – Arun Raja Aug 19 '15 at 04:26