bright data を使って、ポートローテーションをしたいのですが、
プログラムが開始されません。
行いたいこととしては、digital ocean で作成したポートを、proxi server によって変更して、
ターゲットサイトにアクセスすることです。
python
def create_driver(port): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') PROXY = "http:// username : password @localhost:8080" # Create a copy of desired capabilities object. desired_capabilities = webdriver.DesiredCapabilities.CHROME.copy() # Change the proxy properties of that copy. desired_capabilities['proxy'] = { "httpProxy":PROXY, "ftpProxy":PROXY, "sslProxy":PROXY, "noProxy":None, "proxyType":"MANUAL", "class":"org.openqa.selenium.Proxy", "autodetect":False } # you have to use remote, otherwise you'll have to code it yourself in python to # dynamically changing the system proxy preferences driver = webdriver.Remote("http://localhost:4444/wd/hub", options=chrome_options, desired_capabilities=desired_capabilities) driver.maximize_window() return driver



0 コメント