NodeJS Get Completely Rendered HTML Page

╄→尐↘猪︶ㄣ 提交于 2020-01-05 13:33:53

问题


I want to get a html page content from a url using NodeJS after JavaScript is fully loaded and the page is completely rendered, or get the basic html then run all JavaScript files to achieve final content. For example let's assume there is a website based on AngularJS, so the basic html is simple, but after loading all JavaScript codes in the page, page content is completely different. I want to get that final content on my server to find something in it. Any ideas?


回答1:


After-Load is a NodeJS package that works like a charm :

var afterLoad=require('after-load');

then :

afterLoad('http://stackoverflow.com/questions/29366718',function(html){

       console.log(html.indexOf('charm')>0);
         //true 
})



回答2:


Maybe it's too late, but back in the day, PhantomJS solved my problem.



来源:https://stackoverflow.com/questions/29366718/nodejs-get-completely-rendered-html-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!