为啥不使用 Rweibo 呢?
http://cos.name/cn/topic/110179/
http://cos.name/cn/topic/110179/
passwd <- PKI.encrypt(charToRaw(keyword), pubkey_p)
prelogin_url <- paste("http://login.sina.com.cn/sso/prelogin.php?entry=account&callback=sinaSSOController.preloginCallBack&su=&rsakt=mod&client=ssologin.js(v1.4.15)&_=",
floor(as.numeric(Sys.time()) * 1000), sep = "")
head <- c(Connection = "keep-alive",
Host = "login.sina.com.cn",
"User-Agent" = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Content-Length" = 523, "Content-Type" = "application/x-www-form-urlencoded",
Host = "weibo.com",
Referer = "http://login.sina.com.cn/member/my.php?entry=sso",
"Cookie" = cookie)
d2 =debugGatherer()
cHandle2<- getCurlHandle(httpheader=head, followlocation=1,
debugfunction=d2$update,verbose=TRUE,
cookiefile= "cookie.txt")
page <- getURL("http://weibo.com/at/weibo?topnav=1&wvr=5", curl = cHandle2)
page
[1] "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html>\r\n<head><title>403 Forbidden</title></head>\r\n<body bgcolor=\"white\">\r\n<h1>403 Forbidden</h1>\r\n<p>You don't have permission to access the URL on this server. Sorry for the inconvenience.<br/>\r\nPlease report this message and include the following information to us.<br/>\r\nThank you very much!</p>\r\n<table>\r\n<tr>\r\n<td>URL:</td>\r\n<td>http://login.sina.com.cn/at/weibo?topnav=1&wvr=5</td>\r\n</tr>\r\n<tr>\r\n<td>Server:</td>\r\n<td>venus50</td>\r\n</tr>\r\n<tr>\r\n<td>Date:</td>\r\n<td>2015/07/03 23:00:03</td>\r\n</tr>\r\n</table>\r\n<hr/>Powered by WeiBo</body>\r\n</html>\r\n"
> head <- c(Connection='keep-alive',
+ 'User-Agent'='Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0',
+ Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
+ 'Content-Length'=523, 'Content-Type'='application/x-www-form-urlencoded',
+ Host='weibo.com', Referer='http://login.sina.com.cn/member/my.php?entry=sso') #, 'Cookie'=cookie)
> d2 <- debugGatherer()
> cHandle2 <- getCurlHandle(httpheader=head, followlocation=1, debugfunction=d2$update,verbose=TRUE)#, cookiefile='cookie.txt')
> page <- getURL('http://weibo.com/at/weibo?topnav=1&wvr=5', curl = cHandle2)
Error in function (type, msg, asError = TRUE) : Empty reply from server
> page
function (x, method = c("dput", "print"), ...)
{
local.file.show <- function(file, title = subx, delete.file = TRUE,
pager = getOption("pager"), ...) file.show(file, title = title,
delete.file = delete.file, pager = pager)
local.dput <- function(x, file, title, delete.file, pager,
...) dput(x, file, ...)
local.print <- function(x, title, delete.file, pager, ...) print(x,
...)
if (is.character(x) && length(x) == 1L) {
subx <- x
parent <- parent.frame()
if (exists(subx, envir = parent))
x <- get(subx, envir = parent)
else stop(gettextf("no object named '%s' to show", x),
domain = NA)
}
else {
subx <- deparse(substitute(x))
}
file <- tempfile("Rpage.")
if (match.arg(method) == "dput")
local.dput(x, file, ...)
else {
sink(file)
local.print(x, ...)
sink()
}
local.file.show(file, ...)
}
<bytecode: 0x75b8508>
<environment: namespace:utils>