# 快速在多个搜索引擎下搜索同一关键词

**URL:** <https://meta.appinn.net/t/topic/33281>\
**Category:** 讨论分享\
**Tags:** chrome, 搜索引擎\
**Created:** [2022 年6 月 2 日 16:24 UTC](https://meta.appinn.net/t/topic/33281 "2022-06-02T16:24:06Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

作者： ![bcaso](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/bcaso/32/20852_2.png) [@bcaso](https://meta.appinn.net/u/bcaso)\
发布日期： [2022 年6 月 2 日 16:24 UTC](https://meta.appinn.net/t/topic/33281/1 "2022-06-02T16:24:06Z")

</div>

启用 ohmyzsh 的插件 web-search，可以在终端下使用 bing, google, baidu 来打开浏浏器然后搜索东西，但是不够好用。

于是写了个脚本，实现在多个搜索引擎下搜索相同关键词。

无论是在终端下搜索还是在运行窗口下搜索，都会打开新的浏览器窗口，所有页面都在同一窗口下，且整个过程不需要用鼠标。

 

# cygwin shell

文件：`~/bin/s`

```auto
# open chrome in new window，不跟网址时打开的窗口出提示选择 gogole 帐号（多帐号）
chrome --args --new-window https://google.com/search?q="$1"

# search.pi，自建搜索
chrome http://search.pi/query/?q="$1"
# duckduckgo
chrome https://duckduckgo.com/?q="$1"
# bing
chrome https://bing.com/search?q="$1"
# baidu
chrome https://baidu.com/s?wd="$1"

```

后续打开操作不需要加延时.

```auto
~/bin % s test
Opening in existing browser session.

```

其中 chrome 命令是软链接 chrome.exe

```auto
 % file ~/bin/chrome
/home/god/bin/chrome: symbolic link to /cygdrive/c/Program Files/Google/Chrome/Application/chrome.exe

```

举例： `s test`，使用 atl+f4 可以关闭整个窗口。

![image](https://meta-edge.appinn.com/uploads/default/optimized/3X/a/c/acfedd909c3af41151870ba7ac079d18e159aa5e_2_690x63.png)

# python 脚本实现

```auto
#!/usr/bin/python3.9
import os
import sys

args = sys.argv[1:] # 参数是以空格分隔的
# 搜索词
content = '%20'.join(args) # 合为一个字符串时，以空格分隔
chrome = r'"C:\Program Files\Google\Chrome\Application\chrome.exe"'

os.system(f'{chrome} --args --new-window https://google.com/search?q={content}')
os.system(f'{chrome} http://search.pi/query/?q={content}')
os.system(f'{chrome} https://duckduckgo.com/?q={content}')
os.system(f'{chrome} https://bing.com/search?q={content}')
os.system(f'{chrome} https://www.baidu.com/s?wd={content}')
os.system(f'{chrome} https://kagi.com/search?q={content}')

```

上面脚本是没问题的，但可能会有两个错误：

1. chrome 必须用 `r'"C:\Pro..."'` 双重引号加 `r`，不然编译后运行时报错，直接运行不报。
2. content 不能加 “”，不然会报错。

```auto
os.system(f'{chrome} http://search.pi/query/?q="{content}"')

```

> **Summary**
>
> ```auto
> >>> import os
> >>> cmd2 = '"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --new-window https://baidu.com/s?wd="a%20b%20c"'
> >>> os.system(cmd2)
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
> 1
> 
> # wd 后面的参数不加双引号就正常了，但是下面这个在编译后运行时报错，必须给 cmd2 后面的字符串加上 r'"C:\Pro......"' 再次编译运行才正常
> >>> cmd2 = '"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --new-window https://baidu.com/s?wd=a%20b%20c'
> >>> os.system(cmd2)
> 0
> >>>
> 
> ```
> 
> 下面这个脚本有错误，但是在 zsh 下可以正常运行，编译也通过，编译后的 exe 也能在 cygwin shell 下运行，但换到 cmd 下就不行。
> 
> ```auto
> #!/usr/bin/python3.9
> import os
> import sys
> 
> args = sys.argv[1:] # 参数是以空格分隔的
> content = ' '.join(args) # 合为一个字符串时，以空格分隔
> 
> os.system(f'brave --args --new-window https://google.com/search?q="{content}"')
> os.system(f'brave http://search.pi/query/?q="{content}"')
> os.system(f'brave https://duckduckgo.com/?q="{content}"')
> os.system(f'brave https://bing.com/search?q="{content}"')
> os.system(f'brave https://www.baidu.com/s?wd="{content}"')
> os.system(f'brave https://kagi.com/search?q="{content}"')
> 
> ```

不知道为什么，问题已发到：

[https://segmentfault.com/q/1010000041950660](https://segmentfault.com/q/1010000041950660)

求解。

# 运行窗口

在运行窗口实现搜索：

文件：`s.bat`，放到某个环境变量目录下。

```auto
REM open chrome in new window
call "cmd /c start chrome --args --new-window https://google.com/search?q=%1"

REM 延时 1 秒，确保后面的页面都在同一窗口内打开。
ping -n 1 127.0.0.1>nul

REM search.pi
start chrome http://search.pi/query/?q=%1
REM duckduckgo
start chrome https://duckduckgo.com/?q=%1
REM bing
start chrome https://bing.com/search?q=%1
REM baidu
start chrome https://baidu.com/s?wd=%1

REM pause

```

有空格时使用双引号括起来：

 ![image](https://meta-edge.appinn.com/uploads/default/original/3X/f/e/fe510537665a0adc91a966c4d2ab84dfe20f20d2.png)

# 一键清空 run 历史记录

run 运行多了就会有很多历史记录，不好清除。

下面是清空 run 记录的 python 脚本。

`clear.py`

```auto
from winreg import *

# 1. 连接注册表根键
regRoot = ConnectRegistry(None, HKEY_CURRENT_USER)

subDir = r'Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU'
# 2. 获取指定目录下所有键的控制
keyHandle = OpenKey(regRoot, subDir, access=KEY_ALL_ACCESS)

# 3. 存放所有的键名
lis = []
try:
    count = 0
    while True:
        name, value, _type = EnumValue(keyHandle, count)
        print(name, value, _type)
        lis.append(name)

        # 不能在这里删除，因为删除后，列表中的数量就变化了，下一轮执行 EnumValue(keyHandle, count) 时就有问题
        # DeleteValue(keyHandle, k)   
        count += 1
except Exception as err:
    print(err)

# 4. 删除键
for k in lis: DeleteValue(keyHandle, k)

# 5. 关闭
CloseKey(keyHandle)
CloseKey(regRoot)

```

打包为 clear.exe （`pyinstaller -F clear.py`，clear.exe 在 dist 目录下）并放入某个环境变量的目录下，然后就可以运行 `clear` 来清空 run 历史。

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 2 日 23:11 UTC](https://meta.appinn.net/t/topic/33281/2 "2022-06-02T23:11:38Z")

</div>

搜索酱也行。右键点击类别就能批量打开，也可以在设置里设置某一项不参与批量打开

> **[SearchJumper](https://greasyfork.org/zh-CN/scripts/445274-searchjumper)**
>
> 一键即时搜索选定文本或在多个搜索引擎之间快速切换，支持关键词高亮、拖拽搜索、以图搜图、页内查找与自定义引擎。

---

<div class="post-metadata">

作者： ![Don](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/don/32/4183_2.png) [@Don](https://meta.appinn.net/u/Don)\
发布日期： [2022 年6 月 3 日 02:57 UTC](https://meta.appinn.net/t/topic/33281/3 "2022-06-03T02:57:39Z")

</div>

这个脚本挺好使

> **[searchEngineJump 搜索引擎快捷跳转](https://greasyfork.org/zh-CN/scripts/27752-searchenginejump-%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E%E5%BF%AB%E6%8D%B7%E8%B7%B3%E8%BD%AC)**
>
> 方便的在各个搜索引擎之间跳转,增加可视化设置菜单,能更友好的自定义设置,修复百度搜索样式丢失的问题

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 3 日 08:15 UTC](https://meta.appinn.net/t/topic/33281/4 "2022-06-03T08:15:16Z")

</div>

好奇问一句， searchEngineJump 那么多版本，为啥大家都推荐这一个改版呢？是有啥独到之处吗？我试用了一下这一版，和我之前用的改版并没有多大的区别呀。

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 3 日 17:20 UTC](https://meta.appinn.net/t/topic/33281/5 "2022-06-03T17:20:23Z")

</div>

[全网首发！是你没用过的多重搜索技巧 - 奔跑中的奶酪 (runningcheese.com)](https://www.runningcheese.com/multi-search)

用书签实现也不错

---

<div class="post-metadata">

作者： ![Don](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/don/32/4183_2.png) [@Don](https://meta.appinn.net/u/Don)\
发布日期： [2022 年6 月 3 日 23:29 UTC](https://meta.appinn.net/t/topic/33281/6 "2022-06-03T23:29:27Z")

</div>

我是一直以为只有这个版本。。。。  
还有就是看见你推荐那个 感觉有点花里胡哨的 （个人意见）

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 4 日 00:43 UTC](https://meta.appinn.net/t/topic/33281/7 "2022-06-04T00:43:42Z")

</div>

这个也是远古大神nlf的遗产，后来又被y大接手，之后才衍生出这么多版本。我那个花里胡哨是因为我的低级审美水准吧。你可以自己在配置页改css啊，我提供了两套模板——如果你有兴趣的话。

另外搜索酱也支持 bookmarklet 的，而且因为可以分别指向链接、图片、视频、音频、页面。甚至也能直接用快捷键来触发，可玩性应该会比直接的 bookmarklet 更好。

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 4 日 15:00 UTC](https://meta.appinn.net/t/topic/33281/8 "2022-06-04T15:00:12Z")

</div>

搜索酱划词搜索我貌似用了没反应。

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 4 日 22:38 UTC](https://meta.appinn.net/t/topic/33281/9 "2022-06-04T22:38:03Z")

</div>

![PicsArt_06-05-06.35.47](https://meta.appinn.net/uploads/default/original/3X/b/f/bffdb9ed60abb2dfcb787d96603980b1e4356439.jpeg)

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 5 日 03:12 UTC](https://meta.appinn.net/t/topic/33281/10 "2022-06-05T03:12:40Z")

</div>

就是勾选了也没效果

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 5 日 03:13 UTC](https://meta.appinn.net/t/topic/33281/11 "2022-06-05T03:13:15Z")

</div>

就是勾选了没效果

---

<div class="post-metadata">

作者： ![bcaso](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/bcaso/32/20852_2.png) [@bcaso](https://meta.appinn.net/u/bcaso)\
发布日期： [2022 年6 月 5 日 03:22 UTC](https://meta.appinn.net/t/topic/33281/12 "2022-06-05T03:22:03Z")

</div>

我感觉在新窗口批量打开搜索结果会更好一些，找到一两个结果后，就可以关闭整个窗口。

window.open 好像不能在新窗口打开，只能在新标签页打开（当然，也可以先 ctrl+N 创建新窗口，然后使用奶酪给出的方法进行多重搜索，但还是有些麻烦），而且用油猴脚本的话，鼠标点来点去很麻烦。

> [@Wha4Up](#):
>
> [全网首发！是你没用过的多重搜索技巧 - 奔跑中的奶酪 (runningcheese.com)](https://www.runningcheese.com/multi-search)
> 
> 用书签实现也不错

其中，分屏搜索不错，但是需要装插件，且 uBlacklist 不生效，果断放弃。

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 5 日 03:47 UTC](https://meta.appinn.net/t/topic/33281/13 "2022-06-05T03:47:33Z")

</div>

咦，你两个都勾选了吗？难道测出一个bug了？  
你用的什么浏览器和脚本管理器？搜索酱的版本是多少？

我猜是右键事件被鼠标手势之类的扩展拦截掉了？

---

<div class="post-metadata">

作者： ![Hoothin](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/hoothin/32/31202_2.png) [@Hoothin](https://meta.appinn.net/u/Hoothin)\
发布日期： [2022 年6 月 5 日 09:06 UTC](https://meta.appinn.net/t/topic/33281/14 "2022-06-05T09:06:22Z")

</div>

这个需求搜索酱也可以。。。只需要划选关键词之后按住shift+左键点击类别，就能在浏览器新窗口打开这一组所有网站，找到一两个结果之后直接关闭新开窗口就行了。  
也支持给单个类别设置批量打开快捷键，不过快捷键就只能在当前窗口批量打开了。

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 6 日 02:20 UTC](https://meta.appinn.net/t/topic/33281/15 "2022-06-06T02:20:37Z")

</div>

昨天在手机上没细看，最下面的按钮是最近重新更新了吧？前段时间好像不一样。  
现在勾选上可以正常显示了。

---

<div class="post-metadata">

作者： ![Wha4Up](https://meta-edge.appinn.com/user_avatar/meta.appinn.net/wha4up/32/58503_2.png) [@Wha4Up](https://meta.appinn.net/u/Wha4Up)\
发布日期： [2022 年6 月 6 日 02:41 UTC](https://meta.appinn.net/t/topic/33281/16 "2022-06-06T02:41:59Z")

</div>

如果用百度和谷歌需要安装扩展，其他的好像不要
