Google 的一致“我感觉很幸运”宏

arb*_*ark 13 search google-search search-engines

我正在使用 Autohotkey 制作一个小脚本,以快速转到搜索词的第一个 Google 结果。我的问题是,虽然 URL 的行为有点不一致,但我找到的唯一方法是这样做。

http://www.google.com/search?q=searchterm&btnI=745
Run Code Online (Sandbox Code Playgroud)

这仅在第一次命中被认为是非常好的匹配时才有效。否则 Google 会显示正常的 10 个结果。但是,他们首页上实际的“我感觉很幸运”按钮总是将您带到第一个结果。

试试这些链接:

http://www.google.com/search?q=new%20york&btnI=745          <- works
http://www.google.com/search?q=new%20york%20dijon&btnI=745  <- doesn't work
Run Code Online (Sandbox Code Playgroud)

“纽约第戎”在首页上,然后点击“我感觉很幸运”确实有效。

知道如何让它以 URL 形式始终如一地工作吗?

编辑:好的,似乎这在单个 URL 中可能不可行。如果发布,我会将油脂猴脚本解决方法标记为正确。

arb*_*ark 3

制作了一个解决方法 Greasemonkey 脚本:

// ==UserScript==
// @name         Google IFL
// @match        https://*.google.com/*?lucky=*
// @match        http://*.google.com/*?lucky=*
// ==/UserScript==

document.getElementById("gsr").style.display = 'none'; // optional. shows blank screen before forwarding. just looks better imo.
document.getElementById("gbqfq").focus();
var pathname = document.URL;
var start = pathname.indexOf("?lucky=");
var searchterm = pathname.substring(start+7);
document.getElementById("gbqfq").value = decodeURI(searchterm);
var btnLucky = document.getElementsByName('btnI')[0];
btnLucky.click();
Run Code Online (Sandbox Code Playgroud)

如果您导航到,此脚本将始终将您转到 Google 的“我感觉幸运”选项www.google.com/?lucky=searchterm_goes_here

我在 FireFox 中使用它,方法是将关键字添加到书签中www.google.com/?lucky=%s