Playwright Python 的代理问题

问题描述 投票:0回答:1

全部。所以,我将 Brightdata 代理与剧作家代码一起使用 -

from playwright.sync_api import sync_playwright
import os
import time

def run():
    with sync_playwright() as p:
        browser = p.firefox.launch(
            headless=False,
            proxy={
                'server': 'http://XXXXXX:XXXXX', 
                'username': 'xxxxxxxxxxxxx',
                'password': 'xxxxxxxxx'  
        )

        page = browser.new_page()

        # Navigate to the website to check IP
        page.goto('https://www.whatismyip.com/')
        time.sleep(3)
        # Close the browser after interaction
        browser.close()
run()

对于数据中心/普通代理,它工作正常,但在使用住宅旋转代理时。它给我一个错误。

"""
  File "D:\pythonProject\AllProjects\venv\Lib\site-packages\playwright\_impl\_connection.py", line 59, in send
    return await self._connection.wrap_api_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\pythonProject\AllProjects\venv\Lib\site-packages\playwright\_impl\_connection.py", line 513, in wrap_api_call
    raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
playwright._impl._errors.Error: Page.goto: NS_ERROR_PROXY_FORBIDDEN
Call log:
navigating to "https://www.whatismyip.com/", waiting until "load" """"

在他们的文档中,他们提到要安装使用此代理的认证,我这样做了,但仍然收到错误。谁能帮我解决这个问题吗?

我尝试使用其他 Brightdata 住宅代理,但所有代理都给我相同的错误消息。

python web-scraping proxy
1个回答
0
投票

我已经使用我的帐户凭据运行了您的代码,效果很好。页面加载。您的账户有居住许可吗?请联系您的客户经理并确保您的住宅区设置正确。

© www.soinside.com 2019 - 2024. All rights reserved.