Selenium chrome driver socks proxy configuration

后端 未结 3 1935
时光取名叫无心
时光取名叫无心 2021-02-18 18:21

I am having troubles in setting socks proxy for chrome driver

Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.MANUAL);
proxy.setAutodetect(false);
         


        
相关标签:
3条回答
  • 2021-02-18 18:38

    Have you tried using this chromium arg?

    --proxy-server="socks5://host:port"
    
    0 讨论(0)
  • 2021-02-18 18:42
    from selenium.webdriver.firefox.options import Options as ff_options
    random_proxy = "142.54.61.98:120"
    options = ff_options()
    firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
    firefox_capabilities['marionette'] = True
    firefox_capabilities['proxy'] = {
        "proxyType": "MANUAL",
        "httpProxy": random_proxy,
        "ftpProxy": random_proxy,
        "sslProxy": random_proxy
    }
    profile = webdriver.FirefoxProfile()
    profile.set_preference("media.peerconnection.enabled", False)
    profile.set_preference("media.navigator.enabled", False)
    # profile.set_preference("general.useragent.override", user_agent)
    profile.update_preferences()
    
    driver = webdriver.Firefox(capabilities=firefox_capabilities, firefox_profile=profile,
                               firefox_options=options)
    
    0 讨论(0)
  • 2021-02-18 18:44
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--proxy-server=socks5://" + host + ":" + port);
        WebDriver driver = new ChromeDriver(options);
    
    0 讨论(0)
提交回复
热议问题