R - 从HTML表中读取数据

时间:2015-01-18 13:18:25

标签: r web-scraping

我试图从书籍#34; Practical Data Science Cookbook" 代码如下:

year <- 2013

#Acquire offense data
  url <- paste("http://sports.yahoo.com/nfl/stats/byteam?  group=Offense&cat=Total&conference=NFL&year=season_",
         year,"&sort=530&old_category=Total&old_group=Offense")

offense <- readHTMLTable(url, encoding = "UTF-8", colClasses="character")[[7]]

并收到错误:

Error in UseMethod("xmlNamespaceDefinitions") : 
 no applicable method for 'xmlNamespaceDefinitions' applied to an object of class "NULL"

请帮忙

1 个答案:

答案 0 :(得分:0)

解决问题需要配置http代理。 在Windows桌面上编辑R-Studio快捷方式,在R-Studio名称后添加 代理定义

 http_proxy=http://user_id:passwod@your_proxy:your_port/

来源:Proxy settings for R