python: ** is just like that, this information was collected by me~

foreword

Hello! Hello everyone, this is the Demon King~**

Knowledge points:

  • Basic process
  • fiddler captures packets

Development environment:

  • python 3.8 run the code
  • pycharm 2021.2 assist typing code
  • requests third-party modules

If installing python third-party modules:

  1. win + R Enter cmd Click OK, enter the installation command pip install module name (pip install requests) Enter
  2. Click Terminal in pycharm to enter the installation command

How to configure the python interpreter in pycharm?

  1. Select file >>> setting >>> Project >>> python interpreter (python interpreter)
  2. Click on the gear, select add
  3. Add python installation path

How does pycharm install plugins?

  1. Select file >>> setting >>> Plugins
  2. Click on Marketplace and enter the name of the plug-in you want to install. For example: translation plug-in input translation / Chinese plug-in input Chinese
  3. Select the corresponding plug-in and click install.
  4. After the installation is successful, the option to restart pycharm will pop up, click OK, and restart to take effect.

Answers, information, source code click to receive~

code

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. 发送请求
        response = requests.get(url=detail_url, headers=headers)
        # 2. 获取数据
        html_data = response.text
        # 3. 解析数据
        # 正则匹配数据 第一个参数 需要匹配的规则
        # 第一个参数 在哪个字符串里面匹配
        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)

video tutorial

python: That's all it is, this is not the public account information I climbed down~

epilogue

Well, this article of mine ends here!

If you have more suggestions or questions, feel free to comment or private message me! Let's work hard together (ง •_•)ง

Follow the blogger if you like it, or like and comment on my article! ! !

Guess you like

Origin blog.csdn.net/python56123/article/details/124251398