目前,我正在研究 R 中的“getURL”和“download.file”命令。到目前为止,它们都非常有效。
但是,我有一个特定链接的问题,我不知道为什么这个链接不起作用。
运行
getURL
("http://www.r-bloggers.com/improving-script_002-%e2%80%9cmonitor%e2%80%9d/")
产生错误:
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : embedded nul in string: '\037\b'
“download.file”命令还创建了一个奇怪的编码文件:
download.file
("http://www.r-bloggers.com/improving-script_002-%e2%80%9cmonitor%e2%80%9d/",
"test.html")
这对你有用吗?
最佳答案
问题是 URL 中的引号。您需要先对其进行编码。这将正常工作。
getURL(URLencode("http://www.r-bloggers.com/improving-script_002-%E2%80%9Cmonitor%E2%80%9D/"))
关于r - getURL 和 downfile.file 不会下载网页内容 (R),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11806404/