嗨喽!大家好呀,這裡是小熊貓
歡迎加入白嫖Q群: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. 發送請求
歡迎加入白嫖Q群:660193417###
response = requests.get(url=detail_url, headers=headers)
2. 獲取數據
html_data = response.text
3. 解析數據
歡迎加入白嫖Q群:660193417###
# 正則匹配數據 第一個參數 需要匹配的規則
# 第一個參數 在哪個字符串裡面匹配
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)
我是小熊貓,咱們下篇文章見啦(*◡‿◡)
from tqsdk import TqApi, TqAut
Preface I dont know when peop