pyppeteer 使用阿布云代理

proxyHost = 地址proxyPort = 端口代理隧道验证信息proxyServer = "http://" + proxyHost + ":" + proxyPortreturn proxyServerdef Authens():proxyUser = ;proxyPass = ;authen = {"username": "H06H0ZV23O37L9DD", "password": "1FD18905AE24A6E7"}authen = {"proxyUser": proxyUser, "proxyPass": proxyPass}return authenbrowser = await launch(headless=True, args=['--disable-infobars',
"--proxy-server=" + Proxies()]) # headless=True 启动了无头模式,--proxy-server 启动了代理page = await browser.newPage()await page.setUserAgent(
'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1')await page.authenticate(Authens()) # 输入代理账号密码await page.setExtraHTTPHeaders(Proxies())await page.setExtraHTTPHeaders({'http://http-dyn.abuyun.com:9020'})await page.setExtraHTTPHeaders(Authens())

注意:本文归作者所有,未经作者允许,不得转载

本文链接:https://my.lmcjl.com/post/15180.html

展开阅读全文

4 评论

留下您的评论.