close

如何下載javascript的完整網頁內容

這裡有一個簡單的小工具phantomjs script可以完成
phantomjs script可以觸發網頁的javascript並且允許你下載成html檔案

Here is a simple little phantomjs script that triggers javascript on a webpage and allows you to pull it down locally: 

file: get.js 
var page = require('webpage').create(),
  system = require('system'), address;

address = system.args[1];
page.scrollPosition= { top: 4000, left: 0}  
page.open(address, function(status) {
  if (status !== 'success') {
    console.log('** Error loading url.');
  } else {
    console.log(page.content);
  }
  phantom.exit();
});

Use it as follows: 
$> phantomjs /path/to/get.js "http://www.google.com" > "google.html" 

Changing /path/to, url and filename to what you want. 

文章參考http://stackoverflow.com/questions/5901661/wget-javascript

arrow
arrow

    Johnson峰 發表在 痞客邦 留言(0) 人氣()