Showing posts with label download. Show all posts
Showing posts with label download. Show all posts

Saturday, February 13, 2016

Download link for Google Trends data

Enter keywords

You need to be signed in to Google for the link to work. You can enter up to five words.

1:
2:
3:
4:
5:






Once you have downloaded the data, you might want to parse it to get a clean table.

Load file to parse data



Get Google Trends download link with javascript

The URL_GT function I use to collect Google Trends data was previously implemented with R. To make it easier to download Google Trends data, I created a javascript implementation. Use the code below, or get it from Github.

If you want all data, it's enough to enter a keyword. You can add an array of up to five keywords to compare. To download the data, simply click the link generated.


'use strict';

function URL_GT(keyword, country, region, year, month, length){
  
  var start = "http://www.google.com/trends/trendsReport?hl=en-US&q=";
  var end = "&cmpt=q&content=1&export=1";
  var geo = "";
  var date = "";
  var URL = "";
  var month=1;
  var length=3;

  
  //Geographic restrictions
  if(typeof country!=="undefined") {
    geo="&geo=";
    geo=geo + country;
    if(region!==undefined) geo=geo + "-" + region;
  }
  
  if(typeof keyword==="string"){
  var queries=keyword;
  }
  
  if(typeof keyword==="object"){
  var queries=keyword[0];
    for(var i=1; i < keyword.length; i++){
      queries=queries + "%2C" + keyword[i];
    }
  }
  
  //Dates
  if(typeof year!=="undefined"){
    date="&date="
    date=date + month + "%2F" + year + "%20" + length + "m"
  }
  
  URL = start + queries + geo + date + end;
  URL = URL.replace(" ", "%20");
  return(URL);
}
Entertaining Blogs - BlogCatalog Blog Directory
Bloggtoppen.se