在下面的代码中,我使用selenium导线将代理添加到selenium浏览器中。
def Proxy():
global options
with open ('proxies.txt', 'r') as f:
lines = f.read().split("\n")
split_proxies = [line.split(":") for line in lines]
proxies = [{'https:': f"https://{p[2]}:{p[3]}@{p[0]}:{p[1]}"} for p in split_proxies]
#proxies = [{'http:':f"http://{p[2]}:{p[3]}@{p[0]}:{p[1]}",'https:':f"https://{p[2]}:{p[3]}@{p[0]}:{p[1]}"} for p in split_proxies]
options = {
'proxy': random.choice(proxies)
}
print(options)
def Login():
PATH = 'C:\\Users\\royce\\Desktop\\instamoni\\chromedriver.exe'
driver = webdriver.Chrome(PATH, seleniumwire_options=options)
driver.get('https://www.instagram.com/')我已经测试过了,我的代理人还在工作和活着,他们似乎一切都很好。当selenium打开页面时,第一个页面将加载,但表示Not secure connection,尽管它是一个https站点。然后,如果我尝试寻找某件东西或做任何事情,它只是说No internet。在终端中,我也会被抛出错误:
DevTools listening on ws://127.0.0.1:10950/devtools/browser/30122db5-a37d-40d4-8113-f0314768cb6c
[6732:2536:0101/175116.734:ERROR:device_event_log_impl.cc(211)] [17:51:16.734] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not
functioning. (0x1F)
[6732:2536:0101/175116.735:ERROR:device_event_log_impl.cc(211)] [17:51:16.734] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not
functioning. (0x1F)
[6732:2536:0101/175116.736:ERROR:device_event_log_impl.cc(211)] [17:51:16.735] USB: usb_device_handle_win.cc:1020 Failed to read descriptor from node connection: A device attached to the system is not
functioning. (0x1F)发布于 2021-01-01 19:22:25
您尚未配置ssl代理属性。请参考Running Selenium Webdriver with a proxy in Python如何正确配置代理
prox = Proxy()
prox.proxy_type = ProxyType.MANUAL
prox.http_proxy = "ip_addr:port"
prox.socks_proxy = "ip_addr:port"
prox.ssl_proxy = "ip_addr:port"https://stackoverflow.com/questions/65532203
复制相似问题