問題描述現(xiàn)在我要抓取一個網(wǎng)站的截圖。但是我發(fā)現(xiàn)截圖出來的是未執(zhí)行頁面腳本JS的圖,我看了很多文檔和網(wǎng)友解答,無奈自己的搜索能力有點差,一直找不到對應(yīng)的問題解決方案。比如這個頁面有大概幾個XHR類型獲取的數(shù)據(jù)形成的列表,我該如何在頁面完全加載和執(zhí)行JS后再去截圖?下面是我的代碼constphantom=require('phantom');letcount=0;(asyncfunction(){constinstance=awaitphantom.create();constpage=awaitinstance.createPage();conststatus=awaitpage.open('http://wenshu.court.gov.cn/list/list/?sorttype=1&number=TMSVETRT&guid=31e005b5-868f-ae69cf1d-c65e96bcf639&conditions=searchWord+%E5%BD%93%E4%BA%8B%E4%BA%BA+++%E5%BD%93%E4%BA%8B%E4%BA%BA:%E5%BA%84%E6%9C%9D%E6%99%96');awaitpage.evaluate(function(){//是在這里執(zhí)行嗎?有疑問returndocument.body.innerHTML;}).then(function(html){console.log(html);});if(status=='success'){awaitpage.render('./lalal.png');}awaitinstance.exit();})();
nodeJS的phantomJS網(wǎng)站截圖如何等待網(wǎng)頁腳本執(zhí)行完?(比如js執(zhí)行ajax獲取的數(shù)據(jù))
炎炎設(shè)計
2019-05-12 12:38:00