码迷,mamicode.com
首页 > 编程语言 > 详细

[Node.js] Scraping Dynamic JavaScript Websites with Nightmare

时间:2015-09-04 07:15:08      阅读:171      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!