首页 > 编程语言 > 详细

[Node.js] Scraping Dynamic JavaScript Websites with Nightmare

时间:2015-09-04 07:14:00      阅读:335      评论:0      收藏:0      [点我收藏+]

Many websites have more than just simple static content. Dynamic content which is rendered by JavaScript requires browser to be able to scrape data. This video demonstrates how to use Nightmare (which is a wrapper around PhantomJS) to launch a url and scrape dynamic data.

 

import Nightmare from "nightmare";

new Nightmare()
    .goto(‘http://weather.com‘)
    .evaluate(function(){
        // access the dom element
        return document.querySelector(‘.temperature‘).innerText;
    }, function(temperature){
        // get the return value from the first param
        console.log(temperature);
    })
    .run();    

 

[Node.js] Scraping Dynamic JavaScript Websites with Nightmare

原文:http://www.cnblogs.com/Answer1215/p/4781033.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!