在模板引擎中呈现页面后获取页面的来源? [英] Getting source of a page after it's rendered in a templating engine?
问题描述
所以我在一个JS很重的网站上进行一些屏幕抓取。它使用客户端模板引擎呈现所有内容。我尝试使用jQuery并且在控制台中工作,但显然不是在服务器(Nodejs)上。
So I'm doing some screen scraping on a site that is very JS heavy. It uses a client side templating engine that renders all the content. I tried using jQuery and that worked in the console, but not on the server (Nodejs), obviously.
我看了几个Python和Java库,他们似乎能够处理我想要的东西,但我更喜欢一个适用于Node的JS解决方案服务器。
I looked at a few libraries for Python and Java, and they seem to be able to handle what I want, but I would prefer a JS solution that works with a Node server.
有没有办法在使用Node渲染页面后获取完整的页面源?
Is there any way to get the complete source of a page after it's rendered, using Node?
推荐答案
我使用 jsdom 进行屏幕删除,代码就在这里。 ..
I used jsdom for screen scrapping and the code goes here...
var jsdom = require( 'jsdom' );
jsdom.env( {
url: <give_url_of_page_u_want_to_scarpe>,
scripts: [ "http://code.jquery.com/jquery.js" ],
done: function( error, window ) {
var $ = window.$;
// required page is loaded in $....
//you can write any javascript or jquery code get what ever you want
}
} );
这篇关于在模板引擎中呈现页面后获取页面的来源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!