当前位置:

百家号文章网页打印优化

skai 2024-03-22 4781

为方便收集、打印或者复制百度平台百家号的优质文章,可以利用客户端浏览器工具适当调整页面样式。

1、复制下方的代码备用。
2、在PC端浏览器打开需要收集的文章,从上至下滑动浏览完页面,这样全部的图片元素都会载入显示出来。
3、按键盘F12打开“开发人员工具”,在“控制台”里粘贴代码,按回车。
4、页面更新后,还可以先拉动浏览器页面宽度,或按Ctrl+ - 0 +缩放页面。
5、按Ctrl+P呼出浏览器的打印界面,选择另存为PDF,自行调节页面设置和缩放。

根据需要可重复最后两步以达到合适的打印字体大小。

页面微调优化代码如下:

var addurl='<p style="font-size:14pt;text-align:center;">';
addurl+=window.location.href.split('&')[0]+'</p>';
$('#header').insertAdjacentHTML('afterend',addurl); 
$('#ssr-content').firstChild.remove(); 
$('.Wo80H').remove(); $('.tw0jb').remove(); 
$('#commentModule').remove(); 
$('.EaCvy').style.marginRight = '5px';
$('.EaCvy').style.width='auto';
$('.EaCvy').style.marginBottom='0';
$('#ssr-content').lastChild.remove(); 
$('#ssr-content').firstChild.lastChild.remove();
$('#ssr-content').firstChild.style.width='auto';
$('#ssr-content').firstChild.style.paddingTop='0';
$('#ssr-content').firstChild.firstChild.lastChild.remove();
document.getElementsByTagName('img').forEach(function(i){i.style.maxWidth='45%';});
// 最后一句是调整缩小配图宽度的,可自选。

具体操作步骤图示:

第1、2步

傲游截图20240325085736.png

第3、4步

微信截图_20240325090029.png

第5步

微信截图_20240325090138.png

成功保存文章如下

微信截图_20240326220115.png