R的Google趋势

时间:2013-04-29 09:13:19

标签: r

我正在尝试将Google趋势结果导入R。

我尝试过rGtrendsRGoogleTrends。第一个看起来很难下载CSV文件:

> require(devtools)
> install_github("rGtrends","emhart") 
> library(rGtrends)
> my_terms <- c("Twitter", "Myspace") 
> twit_ms <- rGtrends(my_terms) 
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:/.../Documents/R/win-library/3.0/rGtrends/src/pyGTrends.py", line 105, in csv
raise Exception("Could not find requested section")

第二个我在登录时遇到问题(不知道为什么我需要提供我的谷歌用户名和密码?我可以在我的浏览器中探索谷歌趋势而不这样做。)

2 个答案:

答案 0 :(得分:3)

这不是R问题。

快速阅读pyGTrends home pageissues section of rGTrends上的评论部分,可以看到针对此类行为的各种原因的持续列表,似乎主要的罪魁祸首是Google趋势中的身份验证更改。即:有时pyGTrends适用于某些具有2因素身份验证的功能,而其他时候适用于其他功能则不适用;有时用户需要设置cookie,有时不需要。

答案 1 :(得分:1)

试试这个。它应该与最新的Google趋势数据格式一起使用。

require(devtools) 
install_github('googletrend','okugami79')

library(googletrend) 

# You need to Login http://google.com/trends on your browser!! 

x<- gettrend(keyword='Twitter')