Overcoming “Error: unexpected input” in RCurl

烂漫一生 提交于 2019-12-13 06:39:29

问题


I am trying and failing to use RCurl to automate the process of fetching a spreadsheet from a web site, China Labour Bulletin's Strike Map.

Here is the URL for the spreadsheet with the options set as I'd like them:

http://strikemap.clb.org.hk/strikes/api.v4/export?FromYear=2011&FromMonth=1&ToYear=2015&ToMonth=6&_lang=en

Here is the code I'm using:

library(RCurl)
temp <- tempfile()
temp <- getForm("http://strikemap.clb.org.hk/strikes/api.v4/export",
  FromYear="2011", FromMonth="1", 
  ToYear="2015", ToMonth="6",
  _lang="en")

And here is the error message I get in response:

Error: unexpected input in:
"     ToYear=2015, ToMonth=6,
     _"

Any suggestions on how to get this to work?


回答1:


Try enclosing _lang with a backtick.

temp <- getForm("http://strikemap.clb.org.hk/strikes/api.v4/export",
                FromYear="2011",
                FromMonth="1",
                ToYear="2015",
                ToMonth="6",
                `_lang`="en")

I think R has trouble on the argument starting with an underscore. This seems to have worked for me.



来源:https://stackoverflow.com/questions/30643213/overcoming-error-unexpected-input-in-rcurl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!