I'm looking to download Google Trends data from URLs that I create via code. These URLs, when put into the browser (I use firefox) show a save prompt where I can choose to open or save the file when looking through the browser. However, I am hoping to the the same .csv file containing the Google Trends data via code, and I am stuck.
Here is one of the links that my code creates: [Does prompt to download, however is is Google]
I have two issues with this link, It either downloads a .csv file with Chinese characters (Corrupted I believe?), or downloads some HTML (shown below). When the HTML is saved as an HTML file and run, it takes me to the Google Trends homepage, with the seemingly useless URL of:
https://www.google.com/trends/#geo=US&date=now+7-d&cmpt=q&q=debt&hl=en-US&content=1
<html><head><title>Redirecting</title>
<script type="text/javascript" language="javascript">
// Accessing window.external members can cause IE to throw exceptions.
// Any code that acesses window.external members must be try/catch wrapped
/** @preserveTry */
try {
if (top == self) {
if (window.gtbExternal) {
window.gtbExternal.setM();
} else {
window.external.setM();
}
}
}
catch(err) {
}
</script>
<meta http-equiv="refresh" content="0; url='http://www.google.com/trends#geo=US&date=now+7-d&cmpt=q&q=debt&hl=en-US&content=1'">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000cc" vlink="#551a8b" alink="#ff0000"><script type="text/javascript" language="javascript">
location.replace("http://www.google.com/trends#geo\x3dUS\x26date\x3dnow+7-d\x26cmpt\x3dq\x26q\x3ddebt\x26hl\x3den-US\x26content\x3d1")
</script></body></html>
Also, here is the code that I use to download the .csv file, the basic WebClient
download method, the string url
can be substituted with the URL from above.
public static void Download(string url)
{
WebClient webClient = new WebClient();
webClient.DownloadFile(url, @"C:\Users\Sean\Desktop\StockAp\StockApp\StockApp\report.csv");
}
Note: I know WebClient
downloads the HTML from a page, if there is a way to manipulate the URL to get the data in HTML, that of course would be much easier. However, from what I can tell, somehow getting the CSV would be much better.
For those who are looking at this in the future, here is how I found a way to get/gather the data from a Google Trends term.
I began with a method that creates a different URL from scratch based on 2 requirements, query and period. Query is the search term, and period is the length of time into the past you want (limited to last hr, last 4 hrs, last 24 hrs, last week). For those wondering how I figured out the new URL, read this article(http://techslides.com/hacking-the-google-trends-api). It contains a bunch of information relating to multiple ways of gathering Google Trends data.
Here is the code for the URL builder method:
public static string Build(string query, int period)
{
string url;
string start = "http://www.google.com/trends/fetchComponent?hl=en-US&q=";
string geo = "&geo=US";
string end = "&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=300";
string sPeriod = "";
if (period == (1 / 24))
{
sPeriod = "&date=now 1-H";
}
else if (period == (4 / 24))
{
sPeriod = "&date=now 4-H";
}
else if (period == 1)
{
sPeriod = "&date=now 1-d";
}
else if (period == 7)
{
sPeriod = "&date=now 7-d";
}
else {
Console.WriteLine("URL.Build Error: period is not equal to presets");
}
url = start + query + geo + sPeriod + end;
return url;
}
Secondly I took the URL created and downloaded the HTML from said URL using WebClient and stored it into a .txt file via the basic WebClient code in another method seen below:
public static void Download(string url)
{
WebClient webClient = new WebClient();
webClient.Credentials = CredentialCache.DefaultCredentials;
webClient.DownloadFile(url, @"C:\Users\Sean\Desktop\StockApp\StockApp\StockApp\report.txt");
}
This code gives a text file, which contains a line of HTML that is used to create the graph seen at the URL created before (https://www.google.com/trends/fetchComponent?hl=en-US&q=debt&geo=US&date=now%207-d&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=300) Here is that giant line of text:
var chartData = {"columns":[{"id":"d","label":"Date","type":"datetime"},{"role":"annotation","type":"string"},{"p":{"html":true},"role":"annotationText","type":"string"},{"id":"q0","label":"debt","type":"number"},{"role":"annotation","type":"string"},{"p":{"html":true},"role":"annotationText","type":"string"},{"role":"certainty","type":"boolean"}],"headlineDataPoints":[],"width":485,"axisAnnotations":[],"rows":[[{"v":new Date(2016, 10, 14, 20, 30),"f":"Nov 14, 2016, 20:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 14, 21, 30),"f":"Nov 14, 2016, 21:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 14, 22, 30),"f":"Nov 14, 2016, 22:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 14, 23, 30),"f":"Nov 14, 2016, 23:30 GMT"},null,null,63,null,null,true],[{"v":new Date(2016, 10, 15, 0, 30),"f":"Nov 15, 2016, 00:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 15, 1, 30),"f":"Nov 15, 2016, 01:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 15, 2, 30),"f":"Nov 15, 2016, 02:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 15, 3, 30),"f":"Nov 15, 2016, 03:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 15, 4, 30),"f":"Nov 15, 2016, 04:30 GMT"},null,null,68,null,null,true],[{"v":new Date(2016, 10, 15, 5, 30),"f":"Nov 15, 2016, 05:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 15, 6, 30),"f":"Nov 15, 2016, 06:30 GMT"},null,null,69,null,null,true],[{"v":new Date(2016, 10, 15, 7, 30),"f":"Nov 15, 2016, 07:30 GMT"},null,null,66,null,null,true],[{"v":new Date(2016, 10, 15, 8, 30),"f":"Nov 15, 2016, 08:30 GMT"},null,null,69,null,null,true],[{"v":new Date(2016, 10, 15, 9, 30),"f":"Nov 15, 2016, 09:30 GMT"},null,null,79,null,null,true],[{"v":new Date(2016, 10, 15, 10, 30),"f":"Nov 15, 2016, 10:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 15, 11, 30),"f":"Nov 15, 2016, 11:30 GMT"},null,null,54,null,null,true],[{"v":new Date(2016, 10, 15, 12, 30),"f":"Nov 15, 2016, 12:30 GMT"},null,null,55,null,null,true],[{"v":new Date(2016, 10, 15, 13, 30),"f":"Nov 15, 2016, 13:30 GMT"},null,null,63,null,null,true],[{"v":new Date(2016, 10, 15, 14, 30),"f":"Nov 15, 2016, 14:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 15, 15, 30),"f":"Nov 15, 2016, 15:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 15, 16, 30),"f":"Nov 15, 2016, 16:30 GMT"},null,null,77,null,null,true],[{"v":new Date(2016, 10, 15, 17, 30),"f":"Nov 15, 2016, 17:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 15, 18, 30),"f":"Nov 15, 2016, 18:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 15, 19, 30),"f":"Nov 15, 2016, 19:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 15, 20, 30),"f":"Nov 15, 2016, 20:30 GMT"},null,null,71,null,null,true],[{"v":new Date(2016, 10, 15, 21, 30),"f":"Nov 15, 2016, 21:30 GMT"},null,null,68,null,null,true],[{"v":new Date(2016, 10, 15, 22, 30),"f":"Nov 15, 2016, 22:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 15, 23, 30),"f":"Nov 15, 2016, 23:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 16, 0, 30),"f":"Nov 16, 2016, 00:30 GMT"},null,null,63,null,null,true],[{"v":new Date(2016, 10, 16, 1, 30),"f":"Nov 16, 2016, 01:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 16, 2, 30),"f":"Nov 16, 2016, 02:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 16, 3, 30),"f":"Nov 16, 2016, 03:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 16, 4, 30),"f":"Nov 16, 2016, 04:30 GMT"},null,null,66,null,null,true],[{"v":new Date(2016, 10, 16, 5, 30),"f":"Nov 16, 2016, 05:30 GMT"},null,null,63,null,null,true],[{"v":new Date(2016, 10, 16, 6, 30),"f":"Nov 16, 2016, 06:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 16, 7, 30),"f":"Nov 16, 2016, 07:30 GMT"},null,null,75,null,null,true],[{"v":new Date(2016, 10, 16, 8, 30),"f":"Nov 16, 2016, 08:30 GMT"},null,null,82,null,null,true],[{"v":new Date(2016, 10, 16, 9, 30),"f":"Nov 16, 2016, 09:30 GMT"},null,null,93,null,null,true],[{"v":new Date(2016, 10, 16, 10, 30),"f":"Nov 16, 2016, 10:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 16, 11, 30),"f":"Nov 16, 2016, 11:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 16, 12, 30),"f":"Nov 16, 2016, 12:30 GMT"},null,null,58,null,null,true],[{"v":new Date(2016, 10, 16, 13, 30),"f":"Nov 16, 2016, 13:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 16, 14, 30),"f":"Nov 16, 2016, 14:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 16, 15, 30),"f":"Nov 16, 2016, 15:30 GMT"},null,null,71,null,null,true],[{"v":new Date(2016, 10, 16, 16, 30),"f":"Nov 16, 2016, 16:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 16, 17, 30),"f":"Nov 16, 2016, 17:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 16, 18, 30),"f":"Nov 16, 2016, 18:30 GMT"},null,null,71,null,null,true],[{"v":new Date(2016, 10, 16, 19, 30),"f":"Nov 16, 2016, 19:30 GMT"},null,null,72,null,null,true],[{"v":new Date(2016, 10, 16, 20, 30),"f":"Nov 16, 2016, 20:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 16, 21, 30),"f":"Nov 16, 2016, 21:30 GMT"},null,null,67,null,null,true],[{"v":new Date(2016, 10, 16, 22, 30),"f":"Nov 16, 2016, 22:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 16, 23, 30),"f":"Nov 16, 2016, 23:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 17, 0, 30),"f":"Nov 17, 2016, 00:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 17, 1, 30),"f":"Nov 17, 2016, 01:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 17, 2, 30),"f":"Nov 17, 2016, 02:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 17, 3, 30),"f":"Nov 17, 2016, 03:30 GMT"},null,null,58,null,null,true],[{"v":new Date(2016, 10, 17, 4, 30),"f":"Nov 17, 2016, 04:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 17, 5, 30),"f":"Nov 17, 2016, 05:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 17, 6, 30),"f":"Nov 17, 2016, 06:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 17, 7, 30),"f":"Nov 17, 2016, 07:30 GMT"},null,null,70,null,null,true],[{"v":new Date(2016, 10, 17, 8, 30),"f":"Nov 17, 2016, 08:30 GMT"},null,null,73,null,null,true],[{"v":new Date(2016, 10, 17, 9, 30),"f":"Nov 17, 2016, 09:30 GMT"},null,null,72,null,null,true],[{"v":new Date(2016, 10, 17, 10, 30),"f":"Nov 17, 2016, 10:30 GMT"},null,null,66,null,null,true],[{"v":new Date(2016, 10, 17, 11, 30),"f":"Nov 17, 2016, 11:30 GMT"},null,null,58,null,null,true],[{"v":new Date(2016, 10, 17, 12, 30),"f":"Nov 17, 2016, 12:30 GMT"},null,null,48,null,null,true],[{"v":new Date(2016, 10, 17, 13, 30),"f":"Nov 17, 2016, 13:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 17, 14, 30),"f":"Nov 17, 2016, 14:30 GMT"},null,null,66,null,null,true],[{"v":new Date(2016, 10, 17, 15, 30),"f":"Nov 17, 2016, 15:30 GMT"},null,null,67,null,null,true],[{"v":new Date(2016, 10, 17, 16, 30),"f":"Nov 17, 2016, 16:30 GMT"},null,null,69,null,null,true],[{"v":new Date(2016, 10, 17, 17, 30),"f":"Nov 17, 2016, 17:30 GMT"},null,null,68,null,null,true],[{"v":new Date(2016, 10, 17, 18, 30),"f":"Nov 17, 2016, 18:30 GMT"},null,null,68,null,null,true],[{"v":new Date(2016, 10, 17, 19, 30),"f":"Nov 17, 2016, 19:30 GMT"},null,null,66,null,null,true],[{"v":new Date(2016, 10, 17, 20, 30),"f":"Nov 17, 2016, 20:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 17, 21, 30),"f":"Nov 17, 2016, 21:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 17, 22, 30),"f":"Nov 17, 2016, 22:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 17, 23, 30),"f":"Nov 17, 2016, 23:30 GMT"},null,null,55,null,null,true],[{"v":new Date(2016, 10, 18, 0, 30),"f":"Nov 18, 2016, 00:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 18, 1, 30),"f":"Nov 18, 2016, 01:30 GMT"},null,null,52,null,null,true],[{"v":new Date(2016, 10, 18, 2, 30),"f":"Nov 18, 2016, 02:30 GMT"},null,null,50,null,null,true],[{"v":new Date(2016, 10, 18, 3, 30),"f":"Nov 18, 2016, 03:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 18, 4, 30),"f":"Nov 18, 2016, 04:30 GMT"},null,null,56,null,null,true],[{"v":new Date(2016, 10, 18, 5, 30),"f":"Nov 18, 2016, 05:30 GMT"},null,null,58,null,null,true],[{"v":new Date(2016, 10, 18, 6, 30),"f":"Nov 18, 2016, 06:30 GMT"},null,null,56,null,null,true],[{"v":new Date(2016, 10, 18, 7, 30),"f":"Nov 18, 2016, 07:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 18, 8, 30),"f":"Nov 18, 2016, 08:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 18, 9, 30),"f":"Nov 18, 2016, 09:30 GMT"},null,null,71,null,null,true],[{"v":new Date(2016, 10, 18, 10, 30),"f":"Nov 18, 2016, 10:30 GMT"},null,null,65,null,null,true],[{"v":new Date(2016, 10, 18, 11, 30),"f":"Nov 18, 2016, 11:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 18, 12, 30),"f":"Nov 18, 2016, 12:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 18, 13, 30),"f":"Nov 18, 2016, 13:30 GMT"},null,null,57,null,null,true],[{"v":new Date(2016, 10, 18, 14, 30),"f":"Nov 18, 2016, 14:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 18, 15, 30),"f":"Nov 18, 2016, 15:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 18, 16, 30),"f":"Nov 18, 2016, 16:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 18, 17, 30),"f":"Nov 18, 2016, 17:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 18, 18, 30),"f":"Nov 18, 2016, 18:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 18, 19, 30),"f":"Nov 18, 2016, 19:30 GMT"},null,null,58,null,null,true],[{"v":new Date(2016, 10, 18, 20, 30),"f":"Nov 18, 2016, 20:30 GMT"},null,null,54,null,null,true],[{"v":new Date(2016, 10, 18, 21, 30),"f":"Nov 18, 2016, 21:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 18, 22, 30),"f":"Nov 18, 2016, 22:30 GMT"},null,null,46,null,null,true],[{"v":new Date(2016, 10, 18, 23, 30),"f":"Nov 18, 2016, 23:30 GMT"},null,null,42,null,null,true],[{"v":new Date(2016, 10, 19, 0, 30),"f":"Nov 19, 2016, 00:30 GMT"},null,null,40,null,null,true],[{"v":new Date(2016, 10, 19, 1, 30),"f":"Nov 19, 2016, 01:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 19, 2, 30),"f":"Nov 19, 2016, 02:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 19, 3, 30),"f":"Nov 19, 2016, 03:30 GMT"},null,null,42,null,null,true],[{"v":new Date(2016, 10, 19, 4, 30),"f":"Nov 19, 2016, 04:30 GMT"},null,null,45,null,null,true],[{"v":new Date(2016, 10, 19, 5, 30),"f":"Nov 19, 2016, 05:30 GMT"},null,null,45,null,null,true],[{"v":new Date(2016, 10, 19, 6, 30),"f":"Nov 19, 2016, 06:30 GMT"},null,null,47,null,null,true],[{"v":new Date(2016, 10, 19, 7, 30),"f":"Nov 19, 2016, 07:30 GMT"},null,null,51,null,null,true],[{"v":new Date(2016, 10, 19, 8, 30),"f":"Nov 19, 2016, 08:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 19, 9, 30),"f":"Nov 19, 2016, 09:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 19, 10, 30),"f":"Nov 19, 2016, 10:30 GMT"},null,null,57,null,null,true],[{"v":new Date(2016, 10, 19, 11, 30),"f":"Nov 19, 2016, 11:30 GMT"},null,null,50,null,null,true],[{"v":new Date(2016, 10, 19, 12, 30),"f":"Nov 19, 2016, 12:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 19, 13, 30),"f":"Nov 19, 2016, 13:30 GMT"},null,null,41,null,null,true],[{"v":new Date(2016, 10, 19, 14, 30),"f":"Nov 19, 2016, 14:30 GMT"},null,null,38,null,null,true],[{"v":new Date(2016, 10, 19, 15, 30),"f":"Nov 19, 2016, 15:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 19, 16, 30),"f":"Nov 19, 2016, 16:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 19, 17, 30),"f":"Nov 19, 2016, 17:30 GMT"},null,null,37,null,null,true],[{"v":new Date(2016, 10, 19, 18, 30),"f":"Nov 19, 2016, 18:30 GMT"},null,null,40,null,null,true],[{"v":new Date(2016, 10, 19, 19, 30),"f":"Nov 19, 2016, 19:30 GMT"},null,null,38,null,null,true],[{"v":new Date(2016, 10, 19, 20, 30),"f":"Nov 19, 2016, 20:30 GMT"},null,null,36,null,null,true],[{"v":new Date(2016, 10, 19, 21, 30),"f":"Nov 19, 2016, 21:30 GMT"},null,null,36,null,null,true],[{"v":new Date(2016, 10, 19, 22, 30),"f":"Nov 19, 2016, 22:30 GMT"},null,null,36,null,null,true],[{"v":new Date(2016, 10, 19, 23, 30),"f":"Nov 19, 2016, 23:30 GMT"},null,null,34,null,null,true],[{"v":new Date(2016, 10, 20, 0, 30),"f":"Nov 20, 2016, 00:30 GMT"},null,null,33,null,null,true],[{"v":new Date(2016, 10, 20, 1, 30),"f":"Nov 20, 2016, 01:30 GMT"},null,null,33,null,null,true],[{"v":new Date(2016, 10, 20, 2, 30),"f":"Nov 20, 2016, 02:30 GMT"},null,null,37,null,null,true],[{"v":new Date(2016, 10, 20, 3, 30),"f":"Nov 20, 2016, 03:30 GMT"},null,null,35,null,null,true],[{"v":new Date(2016, 10, 20, 4, 30),"f":"Nov 20, 2016, 04:30 GMT"},null,null,39,null,null,true],[{"v":new Date(2016, 10, 20, 5, 30),"f":"Nov 20, 2016, 05:30 GMT"},null,null,41,null,null,true],[{"v":new Date(2016, 10, 20, 6, 30),"f":"Nov 20, 2016, 06:30 GMT"},null,null,45,null,null,true],[{"v":new Date(2016, 10, 20, 7, 30),"f":"Nov 20, 2016, 07:30 GMT"},null,null,43,null,null,true],[{"v":new Date(2016, 10, 20, 8, 30),"f":"Nov 20, 2016, 08:30 GMT"},null,null,54,null,null,true],[{"v":new Date(2016, 10, 20, 9, 30),"f":"Nov 20, 2016, 09:30 GMT"},null,null,48,null,null,true],[{"v":new Date(2016, 10, 20, 10, 30),"f":"Nov 20, 2016, 10:30 GMT"},null,null,56,null,null,true],[{"v":new Date(2016, 10, 20, 11, 30),"f":"Nov 20, 2016, 11:30 GMT"},null,null,71,null,null,true],[{"v":new Date(2016, 10, 20, 12, 30),"f":"Nov 20, 2016, 12:30 GMT"},null,null,61,null,null,true],[{"v":new Date(2016, 10, 20, 13, 30),"f":"Nov 20, 2016, 13:30 GMT"},null,null,44,null,null,true],[{"v":new Date(2016, 10, 20, 14, 30),"f":"Nov 20, 2016, 14:30 GMT"},null,null,40,null,null,true],[{"v":new Date(2016, 10, 20, 15, 30),"f":"Nov 20, 2016, 15:30 GMT"},null,null,42,null,null,true],[{"v":new Date(2016, 10, 20, 16, 30),"f":"Nov 20, 2016, 16:30 GMT"},null,null,42,null,null,true],[{"v":new Date(2016, 10, 20, 17, 30),"f":"Nov 20, 2016, 17:30 GMT"},null,null,41,null,null,true],[{"v":new Date(2016, 10, 20, 18, 30),"f":"Nov 20, 2016, 18:30 GMT"},null,null,40,null,null,true],[{"v":new Date(2016, 10, 20, 19, 30),"f":"Nov 20, 2016, 19:30 GMT"},null,null,44,null,null,true],[{"v":new Date(2016, 10, 20, 20, 30),"f":"Nov 20, 2016, 20:30 GMT"},null,null,43,null,null,true],[{"v":new Date(2016, 10, 20, 21, 30),"f":"Nov 20, 2016, 21:30 GMT"},null,null,43,null,null,true],[{"v":new Date(2016, 10, 20, 22, 30),"f":"Nov 20, 2016, 22:30 GMT"},null,null,41,null,null,true],[{"v":new Date(2016, 10, 20, 23, 30),"f":"Nov 20, 2016, 23:30 GMT"},null,null,43,null,null,true],[{"v":new Date(2016, 10, 21, 0, 30),"f":"Nov 21, 2016, 00:30 GMT"},null,null,48,null,null,true],[{"v":new Date(2016, 10, 21, 1, 30),"f":"Nov 21, 2016, 01:30 GMT"},null,null,47,null,null,true],[{"v":new Date(2016, 10, 21, 2, 30),"f":"Nov 21, 2016, 02:30 GMT"},null,null,48,null,null,true],[{"v":new Date(2016, 10, 21, 3, 30),"f":"Nov 21, 2016, 03:30 GMT"},null,null,52,null,null,true],[{"v":new Date(2016, 10, 21, 4, 30),"f":"Nov 21, 2016, 04:30 GMT"},null,null,53,null,null,true],[{"v":new Date(2016, 10, 21, 5, 30),"f":"Nov 21, 2016, 05:30 GMT"},null,null,57,null,null,true],[{"v":new Date(2016, 10, 21, 6, 30),"f":"Nov 21, 2016, 06:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 21, 7, 30),"f":"Nov 21, 2016, 07:30 GMT"},null,null,64,null,null,true],[{"v":new Date(2016, 10, 21, 8, 30),"f":"Nov 21, 2016, 08:30 GMT"},null,null,83,null,null,true],[{"v":new Date(2016, 10, 21, 9, 30),"f":"Nov 21, 2016, 09:30 GMT"},null,null,100,null,null,true],[{"v":new Date(2016, 10, 21, 10, 30),"f":"Nov 21, 2016, 10:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 21, 11, 30),"f":"Nov 21, 2016, 11:30 GMT"},null,null,49,null,null,true],[{"v":new Date(2016, 10, 21, 12, 30),"f":"Nov 21, 2016, 12:30 GMT"},null,null,49,null,null,true],[{"v":new Date(2016, 10, 21, 13, 30),"f":"Nov 21, 2016, 13:30 GMT"},null,null,55,null,null,true],[{"v":new Date(2016, 10, 21, 14, 30),"f":"Nov 21, 2016, 14:30 GMT"},null,null,59,null,null,true],[{"v":new Date(2016, 10, 21, 15, 30),"f":"Nov 21, 2016, 15:30 GMT"},null,null,60,null,null,true],[{"v":new Date(2016, 10, 21, 16, 30),"f":"Nov 21, 2016, 16:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 21, 17, 30),"f":"Nov 21, 2016, 17:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 21, 18, 30),"f":"Nov 21, 2016, 18:30 GMT"},null,null,62,null,null,true],[{"v":new Date(2016, 10, 21, 19, 30),"f":"Nov 21, 2016, 19:30 GMT (partial data)"},null,null,60,null,null,true]],"showHeadlines":false,"percentData":false,"colors":["#3f85f2"],"height":230}; var htmlChart = new trends.HtmlChart( 'time-chart', chartData.columns, chartData.rows, chartData.headlineDataPoints, null , chartData.showHeadlines,true, chartData.percentData, chartData.colors, chartData.width, chartData.height, chartData.axisAnnotations,true);htmlChart.render();
Using this line of the HTML, I cut down the unnecessary information leaving me with the dates and values of the search which I can then use in my program.
来源:https://stackoverflow.com/questions/40647404/downloading-csv-file-from-google-trends