首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用seleniumwire和代理时,有没有办法修复“没有互联网连接请检查代理服务器”?

在使用seleniumwire和代理时,有没有办法修复“没有互联网连接请检查代理服务器”?
EN

Stack Overflow用户
提问于 2021-01-01 17:52:56
回答 1查看 1.1K关注 0票数 0

在下面的代码中,我使用selenium导线将代理添加到selenium浏览器中。

代码语言:javascript
复制
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。在终端中,我也会被抛出错误:

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-01 19:22:25

您尚未配置ssl代理属性。请参考Running Selenium Webdriver with a proxy in Python如何正确配置代理

代码语言:javascript
复制
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"
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65532203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档