Running selenium behind a proxy server

前端 未结 4 1711
一生所求
一生所求 2020-12-13 15:38

I have been using selenium for automatic browser simulations and web scraping in python and it has worked well for me. But now, I have to run it behind a proxy server. So no

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 16:16

    You need to set desired capabilities or browser profile, like this:

    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", "proxy.server.address")
    profile.set_preference("network.proxy.http_port", "port_number")
    profile.update_preferences()
    driver = webdriver.Firefox(firefox_profile=profile)
    

    Also see related threads:

    • how do i set proxy for chrome in python webdriver
    • Selenium using Python: enter/provide http proxy password for firefox
    • Running Selenium Webdriver with a proxy in Python
    • http://krosinski.blogspot.ru/2012/11/selenium-firefox-webdriver-and-proxies.html

提交回复
热议问题