ulfelder
ulfelder

Reputation: 5335

Overcoming "Error: unexpected input" in RCurl

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?

Upvotes: 0

Views: 900

Answers (1)

TARehman
TARehman

Reputation: 6749

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.

Upvotes: 2

Related Questions