将CSDN博客内容保存为PDF,为方便使用所以保存此文章,参考其他文章,如侵权请告知。
一、CSDN文章保存
1.代开CSDN文章内容
2.按键盘上F12打开浏览器调试模式,打开Console标签。
3.在Console标签页内输入一下代码,然后点击回车。
(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove();
$("aside").remove();
$(".tool-box").remove();
$(".csdn-side-toolbar").remove();
$("main").css('display','content');
$("main").css('float','left');
window.print();
$("tool-box").remove();
})();
4、在弹出的打印页面中将页面设置格式,纵向打印时显示不全,可以调节缩放来保持文章内容完整,若想以后看电子版还能复制文章内容则将边距设置为0,可保持内容完整。
二、保存“博客园”<cnblogs.com>,
可使用下面代码,有点缺陷,会有左边或右边会有空白区域,还需完善。
(function(){
$("#side").remove();
$("#comment_title, #comment_list, #comment_bar, #comment_form, .announce, #ad_cen, #ad_bot").remove();
$(".nav_top_2011, #header, #navigator").remove();
$(".p4course_target, .comment-box, .recommend-box, #csdn-toolbar, #tool-box").remove();
$("aside").remove();
$(".tool-box").remove();
$(".csdn-side-toolbar").remove();
$("#sideBar").remove();
$("#footer").remove();
$("tool-box").remove();
$("home").remove();
$('#forFlow').remove();
$("post_detail");
window.print();
})();