Skip to main content

微信公众号 API 等相关工具

Project description

微信公众号 API 工具

微信公众平台(微信公众号)API 相关工具,提供公众号搜索、文章列表获取、文章内容下载等功能。

项目地址: https://github.com/morning-start/wxmp

项目简介

wxmp 是一个 Python 库,用于与微信公众平台后台 API 进行交互。通过本项目可以:

  • 通过微信登录后的 cookies 获取访问 token
  • 搜索公众号(根据关键词查找公众号信息)
  • 获取指定公众号的文章列表
  • 验证文章链接有效性
  • 下载文章内容并转换为 Markdown 格式
  • 支持时间范围缓存和增量更新
  • 支持并发下载

安装

pip install wxmp

或从源码安装:

git clone https://github.com/morning-start/wxmp.git
cd wxmp
pip install -e .

快速开始

1. 初始化 API

from wxmp import WxMPAPI

cookies = {
    "wxuin": "your_wxuin",
    "pass_ticket": "your_pass_ticket",
}

api = WxMPAPI(cookies)

2. 搜索公众号

response = api.search_fakeid("Python")
for account in response.list:
    print(f"名称: {account.nickname}")

3. 使用时间范围爬虫(推荐)

from wxmp.spider import TimeRangeSpider
from datetime import datetime

spider = TimeRangeSpider.from_cookies_file("cookies.json")
bizs = spider.load_or_search_bizs(["Python编程"])

time_range = TimeRange(
    begin=datetime(2024, 1, 1),
    end=datetime(2024, 12, 31)
)

df = spider.search_articles_content(bizs, time_range)
spider.save_all_article_content(df, save_dir="temp/article_content/")

文档

详细文档请查看 Wiki

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wxmp-2.1.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wxmp-2.1.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file wxmp-2.1.2.tar.gz.

File metadata

  • Download URL: wxmp-2.1.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wxmp-2.1.2.tar.gz
Algorithm Hash digest
SHA256 0d0cf71da1d71c8a58c65ff8f68ebe12199e300e1743ba5b31af8ff72d365b83
MD5 787930a3f58369a4ec65be4916be3232
BLAKE2b-256 1754eb7efa94f445c23822569597f5db380c36e68610ffd5bd11963ac0c3b55b

See more details on using hashes here.

Provenance

The following attestation bundles were made for wxmp-2.1.2.tar.gz:

Publisher: python-publish.yml on morning-start/wxmp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wxmp-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: wxmp-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for wxmp-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 38a4deab9e79308466104a1e8872b1a137ad195bd8f1ce0d5fa7230e19ad2264
MD5 96d6f8297c6f4fc7aa375dbfbd37ec6a
BLAKE2b-256 5453aa1567a815dd787847db220f43e9c5690999a8373a27e809224097f3f07d

See more details on using hashes here.

Provenance

The following attestation bundles were made for wxmp-2.1.2-py3-none-any.whl:

Publisher: python-publish.yml on morning-start/wxmp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page