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 r
Solution 1:
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)
Solution 2:
import time
import random
import requests
from selenium import webdriver
profile = webdriver.FirefoxProfile()
withopen("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(profile)
driver.get("https://www.ipleak.net")
time.sleep(60)
driver.close()
Post a Comment for "How To Set Firefox Profile On Selenium Driver Linux Python"