2016-05-04 24 views
0

在一臺機器(Windows 7)中的代碼工作做好:如何從WWW解析在Windows Server 2012 - 錯誤

library(XML) 
library(RCurl) 
library(xtable) 
library(httr) 
library(xml2) 
theurl <- "https://biz.yahoo.com/c/s.html" 
webpage <- content(GET(theurl)) 
tables <- readHTMLTable(webpage) 
splits <- tables[[length(tables)]] 
splits 

> splits 
Payable Ex\nDate    Company Symbol Optionable? Ratio Announced Add\nTo MyCalendar 
1    <NA>    <NA> <NA>  <NA> <NA>  <NA>    <NA> 
2 May 19 May 20  Alliant Energy LNT   Y 2-1 Apr 20    Add 
3 May 27 May 30 Stock Yards Bancorp SYBT   N 3-2 May 02*    Add 

在Windows Server 2012中存在錯誤:

tables <- readHTMLTable(webpage) 
Error in (function (classes, fdef, mtable) : 
unable to find an inherited method for function ‘readHTMLTable’ for signature ‘"xml_document"’ 

有什麼事情是原因嗎? 有沒有其他的可能性來解析這個www?

回答

1

readHTMLTable不支持https。見readHTMLTable,例如下:

## Not run: 
## This changed to using https: in June 2015, and that is unsupported. 
# u = "http://en.wikipedia.org/wiki/World_population" 
u = "https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population" 

爲了解決同樣的問題,見this answer

相關問題