Get javascript rendered html source using phantomjs

前端 未结 2 1735
无人共我
无人共我 2020-12-13 10:34

First of all, I am not looking for any help in development or testing environment. Also I am new to phantomjs and all I want is just the command line operation of phantomjs

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 11:06

    var pagehtml = page.evaluate("function() {"+ 
      "return '' + document.head.innerHTML + '' + '' + document.body.innerHTML + '';" + 
    "}");
    
    
    fs.write('output.html',pagehtml,'w');
    

提交回复
热议问题