Python - Firefox无头 [英] Python - Firefox Headless

查看:188
本文介绍了Python - Firefox无头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几天里,我一直在使用Selenium,Tor和Firefox作为多任务的组合。我设法用Python编写了一个简单的脚本,通过Selenium来控制Firefox,而Firefox连接到Tor以实现隐私。



现在,我正在寻找一种节省资源的方式,所以我想在无头模式下运行Firefox,我认为这是一个常见的功能,但似乎并不是这样。我正在寻找一种方法来做到这一点。它是Firefox的原因,而不是一些基于终端的浏览器是因为我在Firefox中使用的扩展TorButton。它有内置的JavaScript注入,有助于隐私。

如果有人曾经这样做过(我相信很多人都有!),一些提示将不胜感激,谢谢!

解决方案

xvfb是这样做的常用方法。搜索硒xvfb应该找到很多,如:


  • 是否有可能运行Selenium脚本而不运行X服务器?

  • 如何在Selenium中运行Xvfb?

  • http://www.alittlemadness.com/2008/03/05/running-selenium-headless/


  • 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:

    这篇关于Python - Firefox无头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆