Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set firefox profile on selenium driver linux python

Im looking for a little help to have selenium use my profile for firefox

I have found my firefox profile file location: /root/.mozilla/firefox/abcdefgh.default

import time
import random
import requests
from selenium import webdriver

profile = webdriver.FirefoxProfile()

with open("proxylist.txt") as f: 
     proxy_list = f.read().splitlines()
proxy_ip, proxy_port = random.choice(proxy_list).split(":")

profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxy_ip)
profile.set_preference("network.proxy.http_port", int(proxy_port))
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
driver.get("https://www.ipleak.net")
time.sleep(60)
driver.close()
like image 699
James Avatar asked Oct 22 '25 23:10

James


1 Answers

From the documentation of webdriver.FirefoxProfile:

:args:

profile_directory: Directory of profile that you want to use. This defaults to None and will create a new directory when object is created.

So, the following should work:

profile = webdriver.FirefoxProfile('/root/.mozilla/firefox/abcdefgh.default')
driver = webdriver.Firefox(profile)
like image 100
memoselyk Avatar answered Oct 25 '25 13:10

memoselyk