Azure中的无头浏览器可以使用JavaScript吗? [英] Headless browser in Azure functions JavaScript?

查看:81
本文介绍了Azure中的无头浏览器可以使用JavaScript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用phantomjs,但显然不受支持,有没有办法使用javascript中的azure函数来抓取网站?

I tried using phantomjs but apparently it's unsupported, is there any way to scrape websites using azure functions in javascript?

推荐答案

Azure App Service(包括WebApp,Function App)有很多限制,例如

There are many restrictions on Azure App Service (includes WebApps, Function Apps), such as Win32k.sys (User32/GDI32) Restrictions. So some packages are not supported on Azure App Service, which like PhantomJS/puppteer be required to start a headless browser which needs GDI support to communicate with javascript/nodejs to get DOM node.

您可以通过节点 http.ClientRequest 来抓取静态网页或仅抓取HTML.或Function App中的请求程序包.如果要动态抓取网页的DOM节点,则唯一的方法是在Azure VM上使用PhantomJS/puppteer,而不是Function Apps.

You can scrape a static web page or only HTML via Node http.ClientRequest or Request package in Function App. If to scrape a DOM node of a web page dynamically, the only way is using PhantomJS/puppteer on Azure VM, not Function Apps.

这篇关于Azure中的无头浏览器可以使用JavaScript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆