如何让Selenium使用我的firefox(而不是创建一个新的firefox)

2024-09-26 23:24:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我是硒的新手。
我发现selenium不会使用我的本地firefox浏览器。似乎它创建了一个没有插件的新插件。
但是我想用插件做一些事情,比如:modify request headersaotuproxy。我只在java中找到了设置头的例子。
虽然可以使用webdriver.FirefoxProfile().set_preference('network.proxy.http',....设置代理,但它并不适合我的目标。
所以我觉得让selenium使用我的firefox会很好。但我想不通。你知道吗


Tags: 插件requestselenium浏览器javafirefox事情例子
2条回答

Selenium无法连接到现有浏览器。它只能启动新实例。你知道吗

好的,我找到了回答。给我轮廓路径就是点。你知道吗

def get_ffprofile():
    ff_profile_path = 'C:\\Users\\Kasim\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\my89fce2.default'
    ff_profile = webdriver.FirefoxProfile(ff_profile_path)
    return ff_profile

那么

browser = webdriver.Firefox(firefox_profile=get_ffprofile())

将启动我的浏览器(实际上是一个带有我的自定义配置文件的浏览器实例)

相关问题 更多 >

    热门问题