后端开发|Python教程
python,微信公众号文章
后端开发-Python教程
帝国仿绿茶源码,vscode怎么改成白色,ubuntu安装fictx,tomcat跨应用访问,爬虫目录结构,一键php服务器,学seo好还是新媒体好,刷带网站源码下载lzw
【相关学习推荐:python教学】
微信图片打赏源码,vscode新建c#,ubuntu按S,tomcat jar加载,sqlite3 文件打开,网页游戏插件下载,如何定制企业级前端研发框架,爬虫如何储存信息和视频,php 搜索提示,萝岗seo推广,有了网站源码怎么建站,asp代码添加网页连接,dedecms 清空模板缓存lzw
1.安装wkhtmltopdf
java源码下载云盘,vscode 软件下载,ubuntu保存方法,添加tomcat包,SQLite试查询,什么是二次插件,js前端ui框架商业,chromedp 反爬虫,php一句话木马制作,网络营销(seo),自动刷流量网站源码,百度网页动态效果,杰奇小说模板伪静态,单页面应用模板,教师绩效管理系统asp源码,微擎小程序提示购买lzw
下载地址:/downloads.html
我测试用的是windows的,下载安装后结果如下
2 编写python 代码导出微信公众号文章
不能直接使用wkhtmltopdf 导出微信公众号文章,导出的文章会缺失图片,所以需要使用 wechatsogou 将微信公众号文章页面抓取,之后将html文本转化为pdf
踩坑!!!,看了很多人的代码,都是一个模板,大家都是抄来抄去,结果还是运行不了,可能是因为依赖包更新的原因,也可能是因为我本地没有配置wkhtmltopdf 的环境变量
import osimport pdfkitimport datetimeimport wechatsogou# 初始化APIws_api = wechatsogou.WechatSogouAPI(captcha_break_time=3)def url2pdf(url, title, targetPath): \ 使用pdfkit生成pdf文件 :param url: 文章url :param title: 文章标题 :param targetPath: 存储pdf文件的路径 \ try: content_info = ws_api.get_article_content(url) except: return False # 处理后的html html = f\