我正在尝试访问Wikipedia页面以获取页面列表,并收到以下错误:
library(RCurl)
u <- "http://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=tal&namespace=4"
getURL(u)
[1] "Scripts should use an informative User-Agent string with contact information, or they may be IP-blocked without notice.\n"
Run Code Online (Sandbox Code Playgroud)
我希望通过Wikipedia api访问该页面,但我不确定它是否会起作用.
事实上,其他页面的读取没有问题,例如:
u <- "http://en.wikipedia.org/wiki/Wikipedia:Talk"
getURL(u)
Run Code Online (Sandbox Code Playgroud)
有什么建议?
旁注:总的来说,我宁愿不刮维基页面并通过api,但我担心这些特定的页面还没有通过api ...
svi*_*ick 13
根据文档RCurl
,您可以通过添加httpheader
参数指定其他标头:
getURL(u, httpheader = c('User-Agent' = "Informative string with your contact info"))
Run Code Online (Sandbox Code Playgroud)