我正在尝试使用 Selenium 构建解决方案,我可以使用 Firebase Functions 通过 Selenium 初始化和加载网页吗?
我发现一些资源说“不”;然而他们没有给出任何来源,而且他们已经4岁了……:
- 在 Cloud Functions for Firebase 中使用 Selenium https://stackoverflow.com/questions/45968756/using-selenium-from-within-cloud-functions-for-firebase
- Google Firebase 功能:webdriver.io 获取 html 网站的源代码 https://stackoverflow.com/questions/44130594/google-firebase-functions-webdriver-io-get-source-code-of-a-html-website
我如何或在哪里可以检查这种情况是否仍然存在?
您目前无法使用 Python 在 Google Cloud Functions 中运行 Selenium 脚本。当前公开问题跟踪器中有一个功能请求,可以找到here https://issuetracker.google.com/129757153。
对于 Cloud Functions 的 Node.js 运行时,您可以使用木偶师 https://www.npmjs.com/package/puppeteer其中包括无头 Chrome。我找到了这个blog https://rominirani.com/using-puppeteer-in-google-cloud-functions-809a14856e14详细介绍用例的帖子。
或者,如果您准备好将 Python 换成云功能,我们还提供其他服务,例如:App Engine Flex 和 Cloud Run,您可以在其中使用 Python 运行它。
- 适用于 GAE 的 Python 无头浏览器 https://stackoverflow.com/a/51427118/15803365
- 带有 Cloud Run 的 Python 无头 Chrome https://dev.to/googlecloud/using-headless-chrome-with-cloud-run-3fdp
我也发现了这个GitHub 链接 https://github.com/ccorcos/gcloud-functions-selenium-boilerplate它保证在 Google Cloud Functions 上运行 selenium。如果您喜欢 JavaScript/TypeScript 示例而不是 Python,我建议您尝试此模板。不过,我还没有测试过这一点。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)