[Python] Using proxy in playwright python

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm not sure how proxy is used but I tried something and failed. I got proxy list from this site >> https://www.freeproxylists.net/ After reading the playwright documentation, I feel like this should be the code to connect to free proxy server 203.176.179.255 running on port 8080 and HTTP protocol :

    from playwright.sync_api import sync_playwright
    def run(playwright):
    chromium = playwright.chromium
    browser = chromium.launch(channel='chrome',headless=False,proxy={"server":"http://203.176.179.255:8080"})
    page = browser.new_page()
    page.goto("https://grabify.link/4R47U5")


    with sync_playwright() as playwright:
    run(playwright)


    I got this error and I can't understand what is the problem. I don't know how proxy is used, I did read some articles but none of them helped. Yes, they made me understand what proxy is but none of them helped me with this one.

    File "C:/Users/NNB-Suppliers/AppData/Local/Programs/Python/Python37/playwright test.py", line 12, in <module>
    run(playwright)
    File "C:/Users/NNB-Suppliers/AppData/Local/Programs/Python/Python37/playwright test.py", line 8, in run
    page.goto("https://grabify.link/4R47U5")
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\sync_api\_generated.py", line 7432, in goto
    url=url, timeout=timeout, waitUntil=wait_until, referer=referer
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_sync_base.py", line 104, in _sync
    return task.result()
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_page.py", line 494, in goto
    return await self._main_frame.goto(**locals_to_params(locals()))
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_frame.py", line 136, in goto
    await self._channel.send("goto", locals_to_params(locals()))
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_connection.py", line 44, in send
    lambda: self.inner_send(method, params, False)
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_connection.py", line 387, in wrap_api_call
    return await cb()
    File "C:\Users\NNB-Suppliers\AppData\Local\Programs\Python\Python37\lib\site-packages\playwright\_impl\_connection.py", line 78, in inner_send
    result = next(iter(done)).result()
    playwright._impl._api_types.Error: net::ERR_TIMED_OUT at https://grabify.link/4R47U5
    =========================== logs ===========================
    navigating to "https://grabify.link/4R47U5", waiting until "load"
    ============================================================

    Continue reading...

Compartilhe esta Página