如何在selenium驱动程序linux python上设置firefox配置文件

如何在selenium驱动程序linux python上设置firefox配置文件,python,selenium,Python,Selenium,我正在寻找一些帮助,让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: prox

我正在寻找一些帮助,让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\u directory:要使用的配置文件的目录。 这默认为“无”,并将创建一个新的 创建对象时的目录

因此,以下应该起作用:

profile = webdriver.FirefoxProfile('/root/.mozilla/firefox/abcdefgh.default')
driver = webdriver.Firefox(profile)

如果没有一些示例代码,就不可能知道您正在使用什么库或如何调用it@memoselyk如果你能帮忙,我添加了我的代码thanks@memoselyk现在我一点也不叫它。我不知道该怎么做。现在这就是我的代码,没有任何错误。我想让selenium使用我的iceweasel浏览器,但我唯一能让它工作的方法就是使用firefox驱动程序。我真的很想把它指向我真正的浏览器。或者第二次在iceweasel或firefox上使用我的一个用户配置文件(我也下载了浏览器)。我的操作系统是Kali 2.0,我试着使用我的windows机器,但有很多困难。哇,谢谢你,伙计,哈哈,这么简单的事情花了我这么长时间才弄明白。祝你好运,如果这解决了你的问题,请回答。
profile = webdriver.FirefoxProfile('/root/.mozilla/firefox/abcdefgh.default')
driver = webdriver.Firefox(profile)