因此,基本上我尝试使用来自scrapinghub的Crawlera代理和使用python的windows上的selenium chrome。
我查看了文档,他们建议像这样使用Polipo:
1)将以下行添加到/etc/polipo/config
parentProxy = "proxy.crawlera.com:8010"
parentAuthCredentials = "<CRAWLERA_APIKEY>:"2)将其添加到selenium驱动程序
polipo_proxy = "127.0.0.1:8123"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': polipo_proxy,
'ftpProxy' : polipo_proxy,
'sslProxy' : polipo_proxy,
'noProxy' : ''
})
capabilities = dict(DesiredCapabilities.CHROME)
proxy.add_to_capabilities(capabilities)
driver = webdriver.Chrome(desired_capabilities=capabilities)现在我不想使用Polipo,而是直接使用代理。
有没有办法替换polipo_proxy变量并将其更改为crawlera变量?每次我尝试这样做时,它都没有考虑到它,并且运行时没有使用代理。
Crawlera代理格式类似于以下格式: API密钥:@HOSTPORT
我尝试使用以下代码行添加代理:
chrome_options.add_argument('--proxy-server=http://[API KEY]:@[HOST]:[PORT])但问题是我需要以不同的方式指定HTTP和HTTPS。
提前谢谢你!
发布于 2018-10-22 15:16:02
Polipo不再被维护,因此在使用它时存在挑战。Crawlera需要身份验证,而Chrome驱动程序目前似乎还不支持。您可以尝试使用Firefox webdriver,因为您可以在自定义Firefox配置文件中设置代理身份验证,并使用Running selenium behind a proxy server和http://toolsqa.com/selenium-webdriver/http-proxy-authentication/中所示的配置文件。
我一直在遭受同样的问题,并从中得到了一些解脱。希望它也能对你有所帮助。要解决此问题,您必须使用Firefox驱动程序及其配置文件来以这种方式放置代理信息。
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) 这对我来说完全有效。作为参考,你可以参考上面的网站。
发布于 2021-06-30 17:22:02
Scrapinghub创建一个新项目。您需要使用apikey设置一个转发代理,然后设置webdriver以使用此代理。项目地址为:zyte-smartproxy-headless-proxy
你可以去看看
https://stackoverflow.com/questions/50723713
复制相似问题