2

目前我正在研究 R 中的“getURL”和“download.file”命令。到目前为止,两者都像一个魅力。

但是,我有一个特定链接的问题,我不知道为什么这个链接不起作用。

跑步

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

产生错误:

curlPerform 中的错误(curl = curl,.opts = opts,.encoding = .encoding):在字符串中嵌入 nul:'\037\b'

“download.file”命令还创建了一个奇怪的编码文件:

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

这对你有用吗?

4

1 回答 1

7

问题是 URL 中的引号。您需要先对其进行编码。这将正常工作。

getURL(URLencode("http://www.r-bloggers.com/improving-script_002-%E2%80%9Cmonitor%E2%80%9D/"))
于 2012-08-04T07:43:59.397 回答