gzh_article_stat.py 683 B

12345678910111213141516
  1. from app.infra.shared import AsyncHttpClient
  2. # 抓取公众号粉丝
  3. async def get_gzh_stat_daily(access_token: str, date_string: str):
  4. url = f"https://api.weixin.qq.com/datacube/getarticletotaldetail?access_token={access_token}"
  5. data = {"begin_date": date_string, "end_date": date_string}
  6. headers = {
  7. "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
  8. "Content-Type": "application/json",
  9. }
  10. # 发送请求
  11. async with AsyncHttpClient(timeout=10) as http_client:
  12. response = await http_client.post(url, headers=headers, json=data)
  13. return response