Friday, 12 May 2017

How can NightmareJS return full html source code?

I use nightmare to crawl a web-page, In the window, I can find all items are loaded, but can't get the some item's html code printed.

Any suggestion?

My code.

var Nightmare = require('nightmare');

var nightmare = Nightmare({
   show: true,
   webPreferences: {}})

nightmare
 .goto('http://music.163.com/')
 .viewport(1600, 900)
 .wait(5000)
 .evaluate(function() {
     return document.documentElement.innerHTML;
 })
 .end()
 .then(function(res) {
   console.log('source code:', res); // not all the html code printed!
 });



via rongdong.bai

No comments:

Post a Comment