-
-
Save 321k/823cce9769e58bc14214 to your computer and use it in GitHub Desktop.
Google Trends Downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year=c("2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013") | |
setwd("C:/Users/erik.johansson/Dropbox/Hanken/Gradu") | |
path.daily="C:/Users/erik.johansson/Dropbox/Hanken/Gradu/Trends data" | |
path.weekly="C:/Users/erik.johansson/Dropbox/Hanken/Gradu/Weekly trends data" | |
ftse.components=read.csv("C:/Users/erik.johansson/Dropbox/Hanken/Gradu/4.5.2014/ftse components.csv", sep=",") | |
library(quantmod) | |
downloadGT=function(year, querry){ | |
data=data.frame() | |
for(j in 1:length(year)){ | |
#Download data | |
for(i in 1:12) { | |
date=paste(i, "%2F", year[j], "%201m", sep="") | |
URL=paste("http://www.google.com/trends/trendsReport?hl=en-US&q=", querry, "&date=", date, "&cmpt=q&content=1&export=1", sep="") | |
browseURL(URL) | |
Sys.sleep(1) | |
} | |
Sys.sleep(3) | |
} | |
} | |
downloadWeeklyGT=function(querries) | |
for(i in querries){ | |
URL=paste("http://www.google.com/trends/trendsReport?hl=en-US&q=", i,"&cmpt=q&content=1&export=1", sep="") | |
browseURL(URL) | |
Sys.sleep(2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment