Jos*_*rdt 7 javascript node.js nightmare
我正在cheerio和一些人一起努力nightmare.我之所以使用这两者并不仅仅是cheerio因为我必须操纵网站才能找到我想要抓到的部分而且我发现噩梦非常擅长做这些脚本.
所以,现在我正在使用nightmare直到显示我需要的信息的部分.在那之后,evaluate()我试图以某种方式返回电流html然后传递给cheerio刮板.问题是我不知道如何从document对象中检索html .是否有一个属性从那document返回全身?
这是我正在尝试做的事情:
var Nightmare = require('nightmare');
var nightmare = Nightmare({show:true})
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
var urlWeb = "url";
var selectCity = "#ddl_city"
nightmare
.goto(urlWeb)
.wait(selectCity)
.select('#ddl_city', '19')
.wait(6000)
.select('#ddl_theater', '12')
.wait(1000)
.click('#btn_enter')
.wait('#aspnetForm')
.evaluate(function(){
//here is where I want to return the html body
return document.html;
})
.then(function(body){
//loading html body to cheerio
var $ = cheerio.load(body);
console.log(body);
})
Run Code Online (Sandbox Code Playgroud)