Я хочу скачать твиты (без поиска конкретного вопроса). Я попробовал ваш совет:
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 = "Имя пользователя: Пароль', я получаю результат, который представляет собой текстовый файл, содержащий следующую информацию:
<code><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
Я хочу остаться полностью внутри R и должен использовать Windows. Любой совет, как решить эту проблему?
Заранее спасибо