網頁保存為圖片[rasterizeHTML]


任意打開一個網頁,比如當前這個頁面,或者https://www.qq.com,按F12,在控制台輸入以下腳本,回車。

你會發現整個網站變成了一張圖片~(含屏幕滾動外的部分)

var s = document.createElement('script');
s.src="https://cdn.bootcss.com/rasterizehtml/1.3.0/rasterizeHTML.allinone.js";
s.onload=function(){
    rasterizeHTML.drawDocument(document, {width: document.body.clientWidth}).then(function(res){
            document.body.innerHTML = '頁面截圖已生成:<br/>' + res.image.outerHTML
    });
}
document.head.appendChild(s)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM