打印CSDN博客内容保存内容为PDF

打印CSDN博客内容或者保存内容为PDF
有不少小伙伴都有从CSDN上保存博客为pdf或者直接打印博客的需求,我在网上也搜了几篇文章,这里根据其中的一篇做分享,效果最好。

具体操作步骤如下:

打印CSDN博文内容,将以下js内容全部复制放入Chrome开发者选项里边的console,回车即可。
在这里插入图片描述

(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".csdn-side-toolbar,.template-box,.reward-user-box").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box,#dmp_ad_58").remove();
$("aside").remove();
$(".tool-box").remove();
$(".more-toolbox.more-toolbox-active, .left-toolbox").remove();
$(".bottom-pub-footer.footer-box pub_fo,.pub-footer-new").remove();
$("main").css('display','content'); 
$("main").css('float','left'); 
$("#mainBox").css('width','1048px');
$("#mainBox").css('margin-left','0px');
$("#mainBox").css('margin-right','0px');
//$("[class='main_father clearfix d-flex justify-content-center']").css("width","1048px");
$(".main_father.clearfix.d-flex.justify-content-center").css("width","1048px");
window.print();
$("tool-box").remove();
})();

但是仍有一个问题没有解决就是如下:

对于较长的博客,仍然需要手动点击“展开阅读全文”。
在这里插入图片描述

参考博客:
https://blog.csdn.net/qingyunyuy/article/details/102777801
https://blog.csdn.net/u010954948/article/details/82843105

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值