0

如何调整这个 Google 新闻脚本 - 我假设使用变量 - 将当前年份和当前月份放在布尔搜索中 - 具体来说,以“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);
4

1 回答 1

0

我想找到了我的答案。我不需要使用当前日期论坛插入另一个变量。我可能可以让 Google 用布尔值为我完成所有工作:

过去的 x 个月数记为“m[INSERT NUMBER]” 同样,过去的 x 天数记为“d[INSERT NUMBER]”

所以我脚本中的搜索行将显示为:

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

Google 的 XML API 参考

于 2013-03-01T14:28:22.083 回答