【发布时间】:2017-05-17 11:18:11
【问题描述】:
我正在使用 Horsmenan 抓取网站,以便使用提取的数据构建一些图表。
我设法用我的代码获取了每个主要部分的根元素,但我不知道如何浏览其中的每个元素。
我想做的是用一些子元素构建json,例如:
- 公司名称
- company-stack(包含一个 ul 列表)
这是我目前的代码:
router.get('/', function(req, res, next) {
//All the web scraping magic will happen here
var url = "http://www.welcometothejungle.co/stacks?q=&hPP=30&idx=cms_companies_stacks_production&p=";
const pages = [0,1,2,3,4];
pages.forEach((page) => {
const horseman = new Horseman();
horseman
.open(url + '' + page)
.html('article')
.then((text) => {
console.log(`${text}`);
})
.close();
});
res.render('index', {title :"Done"});
});
如何浏览“文本”结果变量?
【问题讨论】:
标签: javascript html node.js web-scraping node-horseman