问题描述
在过去的几天里,我一直在使用Selenium,Tor和Firefox作为多任务的组合。我设法用Python编写了一个简单的脚本,通过Selenium来控制Firefox,而Firefox连接到Tor以实现隐私。现在,我正在寻找一种节省资源的方式,所以我想在无头模式下运行Firefox,我认为这是一个常见的功能,但似乎并不是这样。我正在寻找一种方法来做到这一点。它是Firefox的原因,而不是一些基于终端的浏览器是因为我在Firefox中使用的扩展TorButton。它有内置的JavaScript注入,有助于隐私。
如果有人曾经这样做过(我相信很多人都有!),一些提示将不胜感激,谢谢!
xvfb是这样做的常用方法。搜索硒xvfb应该找到很多,如:
I've spent the last few days messing around with Selenium, Tor, and Firefox as a combination for multiple tasks. I've managed to write a simple script in Python that takes control of Firefox through Selenium, while Firefox is connected to Tor for privacy.
Now, I'm looking for a way to save resources, so I thought of running Firefox in headless mode, which I thought was a common feature but it doesn't seem to be that. I'm looking for a method to do just that. The reason for it being Firefox and not some terminal based browser is because of the extension "TorButton" that I'm using within Firefox. It has javascript injections built in to it that help with privacy.
If anyone has done this before (which I'm sure many have!), some tips would be greatly appreciated, thank you!
xvfb is a common way of doing this. Searching for "selenium xvfb" should find lots, such as:
- Is it possible to run Selenium scripts without having an X server running, too?
- How do I run Selenium in Xvfb?
- http://www.alittlemadness.com/2008/03/05/running-selenium-headless/
这篇关于Python - Firefox无头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!