@@ -22,8 +22,7 @@ def parse_kv(text):
22
22
23
23
def main ():
24
24
param = parse_kv (sys .argv [1 ])
25
- start = sys .argv [2 ] if len (sys .argv ) > 2 else None
26
- end = sys .argv [3 ] if len (sys .argv ) > 3 else None
25
+ start = int (sys .argv [2 ]) if len (sys .argv ) > 2 else 1
27
26
biz = param .get ('__biz' , '' )
28
27
uin = param .get ('uin' , '' )
29
28
key = param .get ('key' , '' )
@@ -39,11 +38,10 @@ def main():
39
38
name = m .group (1 )
40
39
print (name )
41
40
42
- urls = []
41
+ ofile = open ( f'wx_ { name } .txt' , 'a' )
43
42
wait = 10
44
- i = 0
45
- stop = False
46
- while not stop :
43
+ i = (start - 1 ) * 10
44
+ while True :
47
45
print (f'page: { i // 10 + 1 } ' )
48
46
url = f'https://mp.weixin.qq.com/mp/profile_ext?action=getmsg&__biz={ biz } &f=json&offset={ i } &count=10&is_ok=1&scene=&uin={ uin } &key={ key } &pass_ticket={ pass_ticket } &wxtoken=&appmsg_token={ appmsg_token } &x5=0&f=json'
49
47
j = requests .get (url , headers = headers ).json ()
@@ -56,33 +54,16 @@ def main():
56
54
break
57
55
li = json .loads (j ['general_msg_list' ])
58
56
for it in li ['list' ]:
59
- dt = datetime \
60
- .utcfromtimestamp (it ['comm_msg_info' ]['datetime' ]) \
61
- .strftime ('%Y%m%d' )
62
- if start and dt < start :
63
- stop = True
64
- break
65
- if end and dt > end :
57
+ if 'app_msg_ext_info' not in it :
66
58
continue
67
59
url = it ['app_msg_ext_info' ]['content_url' ]
68
60
if not url : continue
69
61
print (url )
70
- urls . append (url )
62
+ ofile . write (url + ' \n ' )
71
63
wait = 10
72
64
i += 10
73
65
74
- config = {
75
- "name" : f"{ name } { start } -{ end } " ,
76
- "url" : "https://mp.weixin.qq.com" ,
77
- "title" : "#activity-name" ,
78
- "content" : "#js_content" ,
79
- "optiMode" : "thres" ,
80
- "list" : urls ,
81
- }
82
- config_fname = f'config_{ uuid .uuid4 ().hex } .json'
83
- open (config_fname , 'w' , encoding = 'utf-8' ).write (json .dumps (config ))
84
- subp .Popen (f'crawl-epub { config_fname } ' , shell = True ).communicate ()
85
- os .remove (config_fname )
66
+ ofile .close ()
86
67
print ('done...' )
87
68
88
69
if __name__ == '__main__' : main ()
0 commit comments