Skip to content

Commit 0371019

Browse files
committed
add wechat_public_article.py
1 parent 1cb2b5b commit 0371019

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

wechat_public_account.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#-*- coding:UTF-8 -*-
2+
import json
3+
import time
4+
import pdfkit
5+
6+
import requests
7+
8+
base_url = 'https://mp.weixin.qq.com/mp/profile_ext'
9+
10+
11+
# 这些信息不能抄我的,要用你自己的才有效
12+
headers = {
13+
'Connection': 'keep - alive',
14+
'Accept': '* / *',
15+
'User-Agent': '写你自己的',
16+
'Referer': '写你自己的',
17+
'Accept-Encoding': 'br, gzip, deflate'
18+
}
19+
20+
cookies = {
21+
'devicetype': 'iOS12.2',
22+
'lang': 'zh_CN',
23+
'pass_ticket': '写你自己的',
24+
'version': '1700042b',
25+
'wap_sid2': '写你自己的',
26+
'wxuin': '3340537333'
27+
}
28+
29+
30+
31+
def get_params(offset):
32+
params = {
33+
'action': 'getmsg',
34+
'__biz': '写你自己的',
35+
'f': 'json',
36+
'offset': '{}'.format(offset),
37+
'count': '10',
38+
'is_ok': '1',
39+
'scene': '126',
40+
'uin': '777',
41+
'key': '777',
42+
'pass_ticket': '写你自己的',
43+
'appmsg_token': '写你自己的',
44+
'x5': '0',
45+
'f': 'json',
46+
}
47+
48+
return params
49+
50+
51+
def get_list_data(offset):
52+
res = requests.get(base_url, headers=headers, params=get_params(offset), cookies=cookies)
53+
data = json.loads(res.text)
54+
can_msg_continue = data['can_msg_continue']
55+
next_offset = data['next_offset']
56+
57+
general_msg_list = data['general_msg_list']
58+
list_data = json.loads(general_msg_list)['list']
59+
60+
for data in list_data:
61+
try:
62+
if data['app_msg_ext_info']['copyright_stat'] == 11:
63+
msg_info = data['app_msg_ext_info']
64+
title = msg_info['title']
65+
content_url = msg_info['content_url']
66+
# 自己定义存储路径
67+
pdfkit.from_url(content_url, '/home/wistbean/wechat_article/'+title+'.pdf')
68+
print('获取到原创文章:%s : %s' % (title, content_url))
69+
except:
70+
print('不是图文')
71+
72+
if can_msg_continue == 1:
73+
time.sleep(1)
74+
get_list_data(next_offset)
75+
76+
77+
if __name__ == '__main__':
78+
get_list_data(0)

0 commit comments

Comments
 (0)