【问题标题】:Playwright on Azure Functions Python based基于 Python 的 Azure Functions 剧作家
【发布时间】:2021-08-24 20:31:44
【问题描述】:

我正在尝试使用 playwright 抓取网站并将其托管在 Azure Functions 上。但是,playwright 需要 Chrome 驱动程序,我似乎无法将其安装到 Azure Functions 中。

不确定如何在管道中执行此步骤:

pip install playwright
playwright install

以前,我尝试在 azure 管道中执行此操作:

  - script: |
    python -m venv ./azfunc/.python_packages
    source ./azfunc/.python_packages/bin/activate
    python -m pip install --upgrade pip keyring artifacts-keyring
    pip install -r ./azfunc/requirements.txt
    python -m playwright install
  displayName: 'Install dependencies'

但是,我收到了webkit" browser was not found.Please complete Playwright installation via running"python -m playwright install
Azure Function 似乎找不到它的安装位置。有什么建议么?使用 Docker 会是个好策略吗?

【问题讨论】:

    标签: docker azure-functions cloud playwright-python


    【解决方案1】:

    看起来 azure 函数支持带有基于消费的应用服务计划的 headless Chromium。

    这里是了解更多关于running headless chromium in azure functions with playwright的博客

    在这个github issue之上,建议使用azure functions on docker container

    请提交support ticket 和MS Q&A here

    【讨论】:

    • 感谢您的回答。但是,我希望在似乎没有解决方案的 Python 中使用它。无论哪种方式,我都创建了自己的自定义 docker 映像并在其中安装了所有必要的依赖项。
    猜你喜欢
    • 2022-12-22
    • 1970-01-01
    • 2022-06-21
    • 2022-09-24
    • 2022-08-04
    • 2022-11-16
    • 2022-07-20
    • 2021-02-19
    • 2021-08-02
    相关资源
    最近更新 更多