{"id":13456867,"url":"https://github.com/wnma3mz/wechat_articles_spider","last_synced_at":"2025-04-11T03:29:15.172Z","repository":{"id":37334017,"uuid":"123761689","full_name":"wnma3mz/wechat_articles_spider","owner":"wnma3mz","description":"微信公众号文章的爬虫","archived":false,"fork":false,"pushed_at":"2024-04-18T08:29:59.000Z","size":41491,"stargazers_count":3089,"open_issues_count":8,"forks_count":741,"subscribers_count":73,"default_branch":"master","last_synced_at":"2025-04-03T20:44:02.270Z","etag":null,"topics":["officialaccounts","python36","spider","wechat","wechat-official-account"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wnma3mz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-04T06:00:40.000Z","updated_at":"2025-04-03T06:31:18.000Z","dependencies_parsed_at":"2024-01-13T17:48:35.509Z","dependency_job_id":"32a1373a-1609-4d5c-9b15-a10136cb59a9","html_url":"https://github.com/wnma3mz/wechat_articles_spider","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnma3mz%2Fwechat_articles_spider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnma3mz%2Fwechat_articles_spider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnma3mz%2Fwechat_articles_spider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wnma3mz%2Fwechat_articles_spider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wnma3mz","download_url":"https://codeload.github.com/wnma3mz/wechat_articles_spider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335197,"owners_count":21086534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["officialaccounts","python36","spider","wechat","wechat-official-account"],"created_at":"2024-07-31T08:01:29.252Z","updated_at":"2025-04-11T03:29:15.136Z","avatar_url":"https://github.com/wnma3mz.png","language":"Python","funding_links":[],"categories":["Python","Python (1887)"],"sub_categories":[],"readme":"# 微信公众号文章爬虫（微信文章阅读点赞的获取）\n\n![](https://img.shields.io/pypi/v/wechatarticles)![](https://img.shields.io/pypi/l/wechatarticles)[![](https://img.shields.io/badge/docs-building-blue)](https://wnma3mz.github.io/wechat_articles_spider/build/html/index.html)\n\n安装\n\n`pip install wechatarticles`\n\n展示地址：\n\n~~[日更，获取公众号的最新文章链接](https://data.wnma3mz.cn/demo.html)，支持日更阅读点赞评论正文~~\n\n注：本项目仅供学习交流，严禁用于商业用途（该项目也没法直接使用），不能达到开箱即用的水平。使用本项目需要读文档+源码+动手实践，参考示例代码（`test`文件夹下）进行改写。\n\n提示：另外，已经有很多朋友（大佬）通过直接看源码，已经基于这套项目，或者重写，用于各自的需求。\n\n实现思路一:\n\n1. 从微信公众号平台获取微信公众所有文章的url\n2. 登录微信PC端或移动端获取文章的阅读数、点赞数、评论信息\n\n完整思路可以参考我的博客: [记一次微信公众号爬虫的经历（微信文章阅读点赞的获取）](https://wnma3mz.github.io/hexo_blog/2017/11/18/记一次微信公众号爬虫的经历（微信文章阅读点赞的获取）/)\n\n实现思路二：\n\n1. 登陆微信PC端或移动端获取公众号所有文章的url，这种获取到的url数量大于500，具体数量每个微信号不完全一致（目前只能一次性，无法获取第二次！！！请慎重使用`test_GetUrls.py`，最好不用。。。）\n2. 同上种方法，获取文章阅读数、点赞数、评论信息\n\n公开已爬取的公众号历史文章的永久链接，日期均截止commit时间，仅供测试与学习，欢迎各位关注这些优质公众号。\n\n\u003cdetails\u003e\n  \u003csummary\u003e公众号列表\u003c/summary\u003e\n    \u003cli\u003e科技美学\u003c/li\u003e\n    \u003cli\u003e共青团中央\u003c/li\u003e\n    \u003cli\u003e南方周末\u003c/li\u003e\n    \u003cli\u003eAppSo\u003c/li\u003e\n\u003c/details\u003e\n## Notes\n\n项目始于2017年，当前更新于2023年3月\n\n项目代码进行调整，调用以前的接口请使用`pip install wechatarticles`。\n\n1. 爬取失败的时候，可能有以下原因\n   1. **运行的时候需要关闭网络代理（抓包软件），或者添加相关参数**\n   2. 参数是否最新，获取微信相关参数（cookie、token）时，一定要保证是**对应公众号**的任意文章\n   3. 检查代码\n   4. 需要关注对应公众号（Maybe）\n2. 思路一获取url时，每页间隔可以设定久一点，比如3分钟，持续时间几小时（来自网友测试）\n3. 获取文章阅读点赞时，每篇文章可以设定在5-10s左右，过期时间为4小时；若被封，大约5-10分钟就可继续抓取。\n4. 思路二获取url时，如果被封，需要24小时整之后才能重新抓取（该条作废，暂时不能解封）\n\n参数文件说明见[README](https://github.com/wnma3mz/wechat_articles_spider/blob/master/docs)\n\n## python版本\n\n- `python`: 3.6.2、3.7.3\n\n## 功能实现\n\n\u003cdetails\u003e\n  \u003csummary\u003e功能\u003c/summary\u003e\n    公众号相关\n    \u003cli\u003e公众号信息\u003c/li\u003e\n    \u003cli\u003e公众号biz。获取方式：清博、公众号网页\u003c/li\u003e\n    \u003cli\u003e公众号发表文章数量（不完全准确）\u003c/li\u003e\n    文章相关\n    \u003cli\u003e某公众号文章的url。获取方式：公众号网页、PC端微信、移动端微信、微信读书\u003c/li\u003e\n    \u003cli\u003e某公众号所有文章信息（包含点赞数、阅读数、评论信息），需要手动更改循环\u003c/li\u003e\n    \u003cli\u003e某公众号指定文章的信息\u003c/li\u003e\n    \u003cli\u003e支持微信文章下载至本地转为html（图片可选是否保存）\u003c/li\u003e\n\u003c/details\u003e\n\n## API实例\n\n#### 利用公众号网页版获取微信文章url\n此处有次数限制，不可一次获取太多url。解决方案多个账号同时爬取\n[test_WechatUrls.py](https://github.com/wnma3mz/wechat_articles_spider/blob/master/test/test_WechatUrls.py)\n\n#### 登录微信PC端获取文章信息（阅读点赞）\n[test_WechatInfo.py](https://github.com/wnma3mz/wechat_articles_spider/blob/master/test/test_WechatInfo.py)\n\n#### 快速获取大量文章urls（利用历史文章获取链接）\n[test_GetUrls.py](https://github.com/wnma3mz/wechat_articles_spider/blob/master/test/test_GetUrls.py)\n\n#### 微信文章下载为离线HTML（含图片）\n[test_Url2Html.py](https://github.com/wnma3mz/wechat_articles_spider/blob/master/test/test_Url2Html.py)\n\n#### 学习/运行流程\n\n可以看这个[issue](https://github.com/wnma3mz/wechat_articles_spider/issues/38#issuecomment-817256654)，十分感谢大佬简洁的文字说明。\n\n### 相关文档\n\n见博客与下方文档\n\nofficial_cookie和token手动获取方式见[这篇文档](https://github.com/wnma3mz/wechat_articles_spider/blob/master/docs/get_cookie_token.md)\n\nwechat_cookie和appmsg_token手动获取的介绍，可以参考[这篇文档](https://github.com/wnma3mz/wechat_articles_spider/blob/master/docs/get_appmsg_token.md)\n\n**联系注意事项**：\n\n1. 不（能）做自动登录微信公众号、微信\n\n2. 不（能）做实时（获取参数、阅读点赞、获取文章）\n\n3. 换一个公众号、参数过期，均需手动更新，如何获取参数均在文章中提及，请仔细查阅\n\n4. 不能做关键词搜索（即微信搜一搜功能），比如搜索所有含“科技”两个字的文章。\n\nQ \u0026 A\n\n1. 项目能不能正常运行？\n\n     答：项目可正常运行。\n\n2. xxx怎么运行/启动，需要获取哪些参数？\n\n     答：请看源码，并手动运行看看输出报错。\n\n3. xxx参数怎么获取？\n\n     答：文档和博客均描述的很清楚，请仔细阅读。\n\n4. 我要xxxx，需要怎么做？\n\n     答：看文档，看源码\n\n5. 网页每日更新的方式怎么做的？\n\n     答：不是万能key。方案很简单，就是模拟点击+代理软件(Fiddler或Mitmproxy)拦截包，每日抓一次，如果你有更好的方案也欢迎告知。这部分未开源（如果有看到相关完整开源的可以提个issue学习一下），纯粹是因为配环境+定制化太麻烦，而且存在一定的问题。懂的看到这里能够实现的就能实现，如果问我我也不好回答你，太耗时耗力。\n\n6. PC端微信与抓包软件Fiddler是必装的吗？\n\n     答：不是。这个只是我了解(认为)到，这两个是相对最容易完成整个过程的。代替方案：可以抓手机端的微信（安卓和IOS均可，安卓的要root才能抓到阅读点赞）；抓包软件Fiddler这个可替代的很多，只要能进行HTTPS抓包查看数据就行。\n     \n7. 大量公众号的文章怎么抓？\n\n     答：本项目无法实现。没很好的方案，参考5。切换一个公众号的时间成本大概要3-5分钟，视熟练程度而异。\n     \n\n### 广告位\n\n### 附录\n\n问问题的正常方式：\n\n1. 描述清楚你运行的系统环境、Python环境...（这步骤可选择性忽略）\n2. 运行了什么代码（改动了哪部分），报了什么错（请完整截图）？\n3. 自己根据报错做了哪些尝试？（文档中是否有描述？在网上搜索的解决方案有哪些）\n\n编程是实践出真知，运行的正确与否可以**直接试出来**，没必要耽误两个人的时间。如果运行出了问题，请按照以上流程进行提问，**但前提是自己要运行过**。请**直接说问题or需求**，不需要等我回复再说。谢谢！大部分问题均可以交流，如果事无巨细的提问，也接受付费教学。\n\n微信赞赏码\n\u003cfigure class=\"third\"\u003e\n   \u003cimg src=\"https://i.postimg.cc/ZRDqVZ9r/wechat.jpg\" width=\"260\"\u003e\n\u003c/figure\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnma3mz%2Fwechat_articles_spider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwnma3mz%2Fwechat_articles_spider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnma3mz%2Fwechat_articles_spider/lists"}