5

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())
Jan Šuman
  • 61
  • 1
  • 4

1 Answers1

5

You need to have the authenticate arguement before you go to a page, so to properly authenticate the proxy, your code should look like this:

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.authenticate({'username': 'user', 'password': 'passw'})

    await page.goto('https://www.myip.com/')
    input()
    await browser.close()

asyncio.get_event_loop().run_until_complete(main())
cordmana
  • 121
  • 3
  • 12