Question

Currently I am looking into the "getURL" and "download.file" command in R. So far, both worked like a charm.

However, I have problems with one specific link and I don't know why this one doesn't work.

Running

getURL
("http://www.r-bloggers.com/improving-script_002-%e2%80%9cmonitor%e2%80%9d/")

produce the error:

Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : embedded nul in string: '\037\b'

The "download.file" command creates also a weirdly encoded file:

download.file
("http://www.r-bloggers.com/improving-script_002-%e2%80%9cmonitor%e2%80%9d/",
"test.html")

Does this work with you?

Was it helpful?

Solution

The problem are the quotes in the URL. You need to encode it first. This will work properly.

getURL(URLencode("http://www.r-bloggers.com/improving-script_002-%E2%80%9Cmonitor%E2%80%9D/"))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top