用cheerio执行抓取的JavaScript [英] Executing scraped JavaScript with cheerio

查看:102
本文介绍了用cheerio执行抓取的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,其中有一些JS API不会改变dom,但返回一些数字。
我想编写一个NodeJS应用程序来下载这些页面并在下载页面的上下文中执行这些功能。

I have a web page in which there are some JS APIs that don't alter the dom, but return some numbers. I'd like to write a NodeJS application that downloads such pages and executes those functions in the context of the downloaded page.

我正在看cheerio页面抓取..虽然我看到用它来导航和操作DOM是多么容易,但我没有看到任何运行页面功能的权限。是否可以这样做?

I was looking at cheerio for page scraping.. but while I see how easy is it to navigate and manipulate the DOM with it, I don't see any access to running the page functions. Is it possible to do it?

我应该看看jsdom吗?

Should I look, instead, at jsdom?

谢谢

推荐答案

听起来你想使用PhantomJS,它将提供完全渲染的输出,然后使用cheerio。

Sounds like you want to use PhantomJS, which will provide the fully rendered output, and then use cheerio on that.

这篇关于用cheerio执行抓取的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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