Hi. ! Hello, everyone , This is the little panda
Welcome to white whoring Q Group :660193417###
import requests
import re
import json
import os
headers = {
'Host': 'mp.weixin.qq.com',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63060012)',
'Cookie': 'wxuin=2408215323; lang=zh_CN; pass_ticket=TsrY5cXMvTN01ghVFxFxT9k4jdPONJBt8mdl0ta20qxjUHNsnkkWLjib4gXCXSQM; devicetype=android-29; version=2800153f; wap_sid2=CJvmqfwIEooBeV9IQVVCUVAzdVBlWEo5NTlySFpON1Ffek5zTE9qRi1jdWZjVFMyOFYyM0FyVE9RSTRNZ3VuUXFTcU94Q3lKY1VyQlJ2RkEtTWFyRWFLeHhJUTRrWmp0N0VDZ05zOFV4d0kzZ1p5cXBIbTVBbEZGRWJteEt4Q0oxSjY4ZHFhODlaZnMyY1NBQUF+MOXS6ZIGOA1AlU4=',
}
for page in range(0, 3):
url = f'https://mp.weixin.qq.com/mp/profile_ext?action=getmsg&__biz=MzU0MzU4OTY2NQ==&f=json&offset={page * 10}&count=10&is_ok=1&scene=&uin=777&key=777&pass_ticket=&wxtoken=&appmsg_token=1161_7%252BO7mVaQbImKSRrYWqKBnNggweX4WNZaqjadeg~~&x5=0&f=json'
json_data = requests.get(url=url, headers=headers).json()
general_msg_list = json_data['general_msg_list']
general_msg_list = json.loads(general_msg_list)['list']
# print(general_msg_list)
title_list = []
content_url_list = []
for general_msg in general_msg_list:
title = general_msg['app_msg_ext_info']['title']
content_url = general_msg['app_msg_ext_info']['content_url']
multi_app_msg_item_list = general_msg['app_msg_ext_info']['multi_app_msg_item_list']
title_list.append(title)
content_url_list.append(content_url)
for multi_app_msg_item in multi_app_msg_item_list:
title_list.append(multi_app_msg_item['title'])
content_url_list.append(multi_app_msg_item['content_url'])
# print(title_list)
# print(content_url_list)
zip_data = zip(title_list, content_url_list)
for detail_title, detail_url in zip_data:
if not os.path.exists('img/' + detail_title):
os.mkdir('img/' + detail_title)
1. Send a request
Welcome to white whoring Q Group :660193417###
response = requests.get(url=detail_url, headers=headers)
2. get data
html_data = response.text
3. Parsing data
Welcome to white whoring Q Group :660193417###
# Regular match data The first parameter Need matching rules
# The first parameter In which string does it match
img_list = re.findall('data-src="(https://mmbiz\.qpic\.cn/.*?)"', html_data)
print(detail_title)
# print(img_list)
for img in img_list:
if not 'gif' in img:
img_data = requests.get(img).content
img_name = img.split('/')[-2]
print(img_name)
with open(f'img/{detail_title}/{img_name}.jpeg', mode='wb') as f:
f.write(img_data)
I'm a panda , See you in the next article (*◡‿◡)