Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 调整Google新闻脚本以返回当月_Javascript_Variables_Google News_Booleanquery - Fatal编程技术网

Javascript 调整Google新闻脚本以返回当月

Javascript 调整Google新闻脚本以返回当月,javascript,variables,google-news,booleanquery,Javascript,Variables,Google News,Booleanquery,我该如何调整这个谷歌新闻脚本——我假设使用变量——将当前年份和当前月份放在布尔搜索中——特别是以“tabbed.execute(…?)开头的行 我的最终目标是让这个脚本返回当前年份和月份上下文中的搜索词。感谢您对新手的帮助 google.load('search', '1'); function OnLoad() { // create a tabbed mode search control var tabbed = new google.search.SearchControl(

我该如何调整这个谷歌新闻脚本——我假设使用变量——将当前年份和当前月份放在布尔搜索中——特别是以“tabbed.execute(…?)开头的行

我的最终目标是让这个脚本返回当前年份和月份上下文中的搜索词。感谢您对新手的帮助

google.load('search', '1');

function OnLoad() {

  // create a tabbed mode search control
  var tabbed = new google.search.SearchControl();


  // create our searchers.  There will now be 4 tabs.
  tabbed.addSearcher(new google.search.VideoSearch());
  tabbed.addSearcher(new google.search.NewsSearch());
  tabbed.addSearcher(new google.search.BlogSearch());
  tabbed.addSearcher(new google.search.ImageSearch());


  // draw in tabbed layout mode
  var drawOptions = new google.search.DrawOptions();
  drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

  // Draw the tabbed view in the content div
  tabbed.draw(document.getElementById("stephennews"), drawOptions);


  // Search!
  tabbed.execute("'SEARCHTERM1' AND 'SEARCHTERM2' AND '2013' AND 'MARCH'");
}
google.setOnLoadCallback(OnLoad);

我想我找到了答案。我不需要再插入另一个带有当前日期的变量。我可能可以让谷歌用布尔值为我做所有的工作:

过去的x个月数表示为“m[插入编号]” 同样,过去的x天数也记为“d[插入编号]”

因此,我脚本中的搜索行将显示:

tabbed.execute("'SEARCHTERM1' AND 'SEARCHTERM2' AND 'y[1]' AND 'm[1]'");