如何使用Node / Cheerio(或其他工具)从站点抓取全局变量? [英] How can I use Node / Cheerio (or something else) to scrape a global variable from a site?

查看:146
本文介绍了如何使用Node / Cheerio(或其他工具)从站点抓取全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

页面上有一个全局变量,其中包含一个我要为其设置抓取工具的对象。使用Node / Express /潜在的Cheerio做到这一点的最好方法是什么?

There is a global variable on a page that contains an object that I'd like to set up a scraper for. What's the best way to do this with Node / Express / potentially Cheerio?

我了解Cheerio在遍历DOM中的好处,但是我知道我想要的全局变量的名称抓取,只需要按设定的时间表提取其信息即可。

I understand Cheerio's benefit in traversing a DOM, but I know the name of the global variable I want to scrape and just need to extract its information on a set schedule

推荐答案

Cheerio只是一个dom解析器,因此您将无法访问

Cheerio is just a dom parser, so you wont have acces to any javascriot or any javascript generated content.

您需要的是类似 PhantomJS 模拟浏览器。
看看这个 Stackoverflow答案

What you need is something like PhantomJS that simulates a browser. Have a look at this Stackoverflow answer

这篇关于如何使用Node / Cheerio(或其他工具)从站点抓取全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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