我希望从我通过代码创建的网址下载Google趋势数据。当这些URL放入浏览器(我使用firefox)时会显示一个保存提示,我可以选择在查看浏览器时打开或保存文件。但是,我希望通过代码包含Google趋势数据的相同.csv文件,我被困住了。
以下是我的代码创建的链接之一:[提示下载,不过是Google]
这个链接有两个问题,它要么下载带有中文字符的.csv文件(我相信已损坏?),要么下载一些HTML(如下所示)。当HTML保存为HTML文件并运行时,它会将我带到Google趋势主页,其中包含看似无用的网址:
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>
此外,这是我用来下载.csv文件的代码,基本的WebClient
下载方法,字符串url
可以用上面的URL代替。
public static void Download(string url)
{
WebClient webClient = new WebClient();
webClient.DownloadFile(url, @"C:\Users\Sean\Desktop\StockAp\StockApp\StockApp\report.csv");
}
注意:我知道WebClient
从页面下载HTML,如果有办法操纵URL以获取HTML格式的数据,那当然会更容易。但是,据我所知,以某种方式获取CSV会好得多。
答案 0 :(得分:2)
对于那些正在考虑将来的人,我在这里找到了一种从Google趋势术语中获取/收集数据的方法。
我开始使用一种方法,根据2个要求,查询和句点从头开始创建不同的URL。查询是搜索词,句点是您想要的过去时间长度(限于最后一小时,最后4小时,过去24小时,上周)。对于那些想知道我如何计算新网址的人,请阅读这篇文章(http://techslides.com/hacking-the-google-trends-api)。它包含大量有关收集Google趋势数据的多种方式的信息。
以下是URL构建器方法的代码:
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;
}
其次,我使用WebClient从所述URL创建并下载了HTML,并通过基本WebClient代码将其存储到.txt文件中,如下所示:
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");
}
此代码提供了一个文本文件,其中包含一行HTML,用于创建在之前创建的URL(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)上看到的图表。这是巨型文本行:
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();
使用HTML的这一行,我减少了不必要的信息,留下了我可以在我的程序中使用的搜索日期和值。