我正在寻找一些帮助让 selenium 使用我的 firefox 个人资料
我找到了我的 Firefox 配置文件位置:/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()
从文档webdriver.FirefoxProfile
:
:args:
profile_directory:您要使用的配置文件的目录。
默认为 None 并将创建一个新的
创建对象时的目录。
所以,下面的should work:
profile = webdriver.FirefoxProfile('/root/.mozilla/firefox/abcdefgh.default')
driver = webdriver.Firefox(profile)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)