2
我想下载推文(不搜索特定问题)。我想你的建议是:Twitter,错误:401访问'/1/statuses/sample.json'。原因:未授权
curlPerform(url = https://stream.twitter.com/1/statuses/sample.json -u USER:PASSWORD -o "somefile.txt"
# set the directory
setwd("C:\\")
#### redirects output to a file
WRITE_TO_FILE <- function(x) {
if (nchar(x) >0) {
write.table(x, file="Twitter Stream Capture.txt", append=T, row.names=F, col.names=F)
}
}
### windows users will need to get this certificate to authenticate
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
### write the raw JSON data from the Twitter Firehouse to a text file
getURL("https://stream.twitter.com/1/statuses/sample.json",
cainfo = "cacert.pem",
write=WRITE_TO_FILE)
只有我压抑“userpwd =“用户名:密码:”我得到的结果,这是一个包含以下信息的文本文件:
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
<title>Error 401 Unauthorized</title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing '/1/statuses/sample.json'. Reason:
<pre> Unauthorized</pre>
我期待R内部完全停留,并需要使用Windows。如何解决这个问题有什么建议?提前
感谢
谢谢。我用我的Twitter用户名和密码替换了用户名和密码,但不幸的是我没有解决问题。我得到了:function(x){if(nchar(x)> 0){write.table(x,file =“twitter_stream_capture.txt”,append = TRUE,row.names = FALSE,col.names = FALSE)read。表格(“Twitter Stream Capture.txt”)1 \ n
\ n \ n我上面发布的代码完全适合RCurl_1.6-10.1。 – jbaums 2012-02-15 17:14:53
谢谢。我意识到我的是RCurl_1.91-1.1 bitops_1.0-4.1。它应该是一个问题吗?或者可能是我试图'访问'file ='twitter_stream_capture.txt'中的数据? (我用'readHTMLTable')? – 2012-02-22 12:55:05