登录网站以使用RCurl获取数据 [英] log into a website to grab the data using RCurl

查看:96
本文介绍了登录网站以使用RCurl获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用RCurl登录到网站并从Web上获取数据(如果不登录,则无法看到数据.)

I wanted to login to the website using RCurl and grab the data from the web (The data cannot be seen without logging in.)

我想导出此文件(例如)" http://www.omegahat.org/RCurl/philosophy.html .

I wanted to export this (for example) "http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone" into R after I log in using RCurl. The issue is I cannot log in using RCurl. I haven't tried this before so mostly I referred to http://www.omegahat.org/RCurl/philosophy.html.

这就是我尝试过的. (在这里,"me@gmail.com"是我的用户ID,"9999"是我的密码-我刚刚输入了密码.)

So here's what I tried. (here, 'me@gmail.com' is my user ID and '9999' is my Password - i just made it up.)

library(RJSONIO)
library(rjson)
library(RCurl)
appannie <- getURL("http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/.json?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone, userpwd = me@gmail.com:9999", verbose = TRUE)

但这给了我以下信息:

About to connect() to www.appannie.com port 80 (#0)
*   Trying 69.167.138.64... * connected
* Connected to www.appannie.com (69.167.138.64) port 80 (#0)
> GET /app/ios/instagram/ranking/history/chart_data/?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone HTTP/1.1
Host: www.appannie.com
Accept: */*

< HTTP/1.1 403 FORBIDDEN
< Server: nginx/1.1.19
< Date: Fri, 01 Mar 2013 23:41:32 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Keep-Alive: timeout=10
< Vary: Accept-Encoding
< Vary: Cookie,Accept-Encoding
< 
* Connection #0 to host www.appannie.com left intact

因此,我回头阅读了 http://www.omegahat.org/RCurl/philosophy.html又一次又不知道该怎么办,所以在看到stackoverflow中的类似问题之后,我尝试了此操作.

So, I went back and read this http://www.omegahat.org/RCurl/philosophy.html again and didn't know what to do, so I tried this after I saw the similar question from stackoverflow.

getURL("http://www.appannie.com/app/ios/instagram/ranking/history/chart_data/?s=2010-10-06&e=2012-06-04&c=143441&f=ranks&d=iphone",.opts=list(userpwd=me@gmail.com:9999"))

但这给了我下面的输出.

But this gives me below output.

[1] ""

有人可以给我一个提示吗? (经过一堆不同的试用后,网站开始向我发送警告=(

Can anyone give me a hint? (After a bunch of different trial, the website starts to send me warnings =(

推荐答案

这是某种身份验证问题,不是您最有可能在RCurl上做错的事情.

This is some sort of authentication issue not anything you did wrong with RCurl most likely.

您已进入服务器,但您的登录错误,无效或无法通过API获得数据.

You got through to the server but either your login was incorrect, it wasn't valid or the data is not available via the API.

http://en.wikipedia.org/wiki/HTTP_403

这篇关于登录网站以使用RCurl获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆