gzh_article_stat.py 708 B

123456789101112131415161718192021
  1. from applications.utils 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 = {
  6. "begin_date": date_string,
  7. "end_date": date_string
  8. }
  9. headers = {
  10. "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",
  11. "Content-Type": "application/json"
  12. }
  13. # 发送请求
  14. async with AsyncHttpClient(timeout=10) as http_client:
  15. response = await http_client.post(url, headers=headers, json=data)
  16. return response