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!
Since version 56 release at September 28, 2017, Firefox headless mode is available in all three main operating system.
You can set headless mode through
webdriver.FirefoxOptions()
, just like you did with Chrome:P.S. If you use Selenium < 3.8.0, you have to replace
webdriver.FirefoxOptions()
withwebdriver.firefox.options.Options()
(see PR #5120).Besides, use enviroment variable
MOZ_HEADLESS
will do the same thing:There is progress being made on headless firefox.
From April 21st, 2017, https://adriftwith.me/coding/2017/04/21/headless-slimerjs-with-firefox/
xvfb is a common way of doing this. Searching for "selenium xvfb" should find lots, such as:
Or alternatively use a true headless browser, like Phantomjs which is light weighted and nicely integrated with selenium
if finally find the answer:
First, of first do these:
Take care that you set fire fox drive path correctly.
And then:
And at the end run this command to see that do we have any error in our implementation of not.
and if there no any output just click ctrl+c.
Ok, after that write this codes.