Python pyppeteer proxy usage

老子叫甜甜 提交于 2020-06-17 02:37:09

问题


I want to run chromium browser using auth proxy. I have this code, but chromium does not connect via the proxy. Any suggestions please?

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch({'http_proxy': 'ip:port', 'headless': False })
    page = await browser.newPage()
    await page.goto('https://www.myip.com/')
    await page.authenticate({'username': 'user', 'password': 'passw'})
    input()
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

EDIT: Got the proxy working, EXCEPT the authentication.

import asyncio
from pyppeteer import launch

async def main():
    browser = await launch({'args': ['--proxy-server=ip:port'], 'headless': False })
    page = await browser.newPage()
    await page.goto('https://www.myip.com/')
    await page.authenticate({'username': 'user', 'password': 'passw'})
    input()
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())

来源:https://stackoverflow.com/questions/59270710/python-pyppeteer-proxy-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!