• 微信公众号文章提取并保存为PDF


    有时会看到非常好的公众号文章想保存下来供以后参阅,避免文章被删的情况,笔者介绍几种方法以供参考。

    手动保存

    找到公众号链接,如下篇:https://mp.weixin.qq.com/s/8fhYaOnAwqCOZwip__3zcg

     

     

    在浏览器打开

     

     

     

    然后 ctrl+p 

     

     

     

     点击保存即可。

     

    存在问题,有的图片无法显示,可以在预览完成之后再保存。

     

    利用python下载保存

     

    首先,下载安装wkhtmltopdf,下载地址:https://wkhtmltopdf.org/downloads.html

     

     

    记住安装的文件夹,添加环境变量。

     

     

     

    打开cmd, 输入“ wkhtmltopdf ”,检查是否安装完成。

     

     

     

    安装 pdfkit包,这个包是 wkhtmltopdf 实用程序,用于使用 Webkit 将 HTML 转换为 PDF

    pip install pdfkit  (or pip3 for python3)
    

     

    用法 

    打开 IDLE

     

    import pdfkit
    
    pdfkit.from_url('http://360.com', 'out.pdf')
    pdfkit.from_file('test.html', 'out.pdf')
    pdfkit.from_string('Hello!', 'out.pdf')
    

      

    输出即为PDF,完成显示True.

     

    默认保存在python 的根目录下。

     

     

    多个链接同时保存

    pdfkit.from_url(['google.com', 'yandex.ru', 'engadget.com'], 'out.pdf')
    

      

     

    用编辑器完成代码:

    import pdfkit
    
    url = 'https://mp.weixin.qq.com/s/8fhYaOnAwqCOZwip__3zcg'
    pdfkit.from_url(url, 'out.pdf')
    

      

    三行代码,即可下载。

    import pdfkit
    
    url = ['https://cn.bing.com','baidu.com']
    
    pdfkit.from_url(url, 'out.pdf')
    

      

      

  • 相关阅读:
    ibatis的优缺点及可行性分析
    NHibernate优点和缺点:
    IbatisNet的介绍和使用
    bat(续七)-for语句(循环结构)
    bat(续五)-获取批处理文件所在路径
    Shell函数参数
    Shell函数:Shell函数返回值、删除函数、在终端调用函数
    Shell break和continue命令
    Shell until循环
    Shell while循环
  • 原文地址:https://www.cnblogs.com/adam012019/p/15620332.html
Copyright © 2020-2023  润新知