用的getURL()在RCurl包命令ViralHeat API问题 [英] ViralHeat API issues with getURL() command in RCurl package

查看:225
本文介绍了用的getURL()在RCurl包命令ViralHeat API问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到使用病毒热API,使用R编程我不是在开玩笑(例如)的情绪。我用的getURL在RCurl包,如下所示:

I am trying to find the sentiment of "I am not joking" (For Example) using viral Heat API using R programming. I used getURL in RCurl package as shown below:

的getURL(的https://www.viralheat.com/api/sentiment/review.json?text=i%20am%20happy&api_key=\", ssl.verifypeer = FALSE)

getURL("https://www.viralheat.com/api/sentiment/review.json?text=i%20am%20happy&api_key=", ssl.verifypeer=FALSE)

这是谷歌浏览器工作正常。但在IE是越来越重定向到 https://www.viralheat.com/browsers 为ViralHeat API是不能IE版本&LT的; 9。

This is working fine in Google Chrome. But in IE it is getting redirected to "https://www.viralheat.com/browsers" as the ViralHeat API is incapable of IE Ver<9.

我改变了R_BROWSER ENV选项,谷歌浏览器(这是我的默认浏览器)。但仍的getURL IE使用作为上述的getURL命令的执行仍然重定向到浏览器页面。我升级IE浏览器版本为11。不过貌似都因为它仍然得到重定向到浏览器页面viralheatAPI不能在IE浏览器。

I changed the R_BROWSER env option to Google Chrome (which is my default browser). But getURL still uses IE as on execution of the above getURL command still redirects to browsers page. I upgraded the IE version to 11. But looks like viralheatAPI doesn't work on IE at all as it still getting redirected to browsers page.

任何人都面临着这个问题?

Anybody faced this issue?

推荐答案

请求。他们应该用RCurl自己的图书馆制作的HTTP请求。​​

Requests made by RCurl do not use your browser. They should use RCurl's own library for making HTTP requests.

最有可能的网站检查请求的用户代理串,看看它的东西是一个有效的浏览器。 RCurl似乎默认不喜欢你的浏览器来指定一个用户代理字符串。如果你想模仿Chrome,前往 http://www.whatsmyuseragent.com/ 看到你当前用户代理字符串。该值复制到R中的变量,然后运行

Most likely the website checks the useragent string of the request to see it something is a valid browser. RCurl does not seem to specify a useragent string by default like your browser does. If you want to impersonate Chrome, go to http://www.whatsmyuseragent.com/ to see what your current useragent string is. Copy that value to a variable in R, then run

ua <- "<your full user agent here>"
getURL("https://www.viralheat.com/api/sentiment/review.json?text=i%20am%20happy&api_key=", 
    ssl.verifypeer=FALSE, .opts=list(useragent=ua))

和应该避免浏览器嗅探一步,至少让你的API。

and that should avoid the browser sniffing step to at least get you to the API.

这篇关于用的getURL()在RCurl包命令ViralHeat API问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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