preface

The text and pictures in this article come from the network, only for learning, communication, do not have any commercial purposes, if you have any questions, please contact us to deal with.

Basic Environment Configuration

  • Python 3.6
  • pycharm
  • requests
  • parsel
! [](https://p6-tt-ipv6.byteimg.com/large/pgc-image/afb037d1f38c4b728bfde1ffaad64a47)
! [](https://p26-tt.byteimg.com/large/pgc-image/653e8f80644149a69b41ff8632db8b45)

Open the developer tools analysis page

! [](https://p9-tt-ipv6.byteimg.com/large/pgc-image/01c7c46151314fd9ab493bd63d4a1650)

How do you know this is the download address?

Open the developer tool, clear the data, and select Network. 3. Click Download Now

! [](https://p3-tt-ipv6.byteimg.com/large/pgc-image/f6ca6f3f9e3f42629bec082f4f0101a2)

Copy the link address and search in the source code of the page to see if the page returns the data

  • There is data: you can directly request the web page to obtain the address;
  • No data: it is necessary to find whether there is interface data in the development of this tool, and then step by step in the analysis;

Implementation effect

! [](https://p26-tt.byteimg.com/large/pgc-image/1c523b1d661140bc817ba39f820e907d)
! [](https://p26-tt.byteimg.com/large/pgc-image/ecf7ae1c53f945c6bff57a1febcd6b96)

The complete code

import requests
import parsel

def download(url, title):
    path = 'D:\\python\\demo\\应用宝手机APP软件\\APP软件\\' + title + '.apk'
    response = requests.get(url=url, headers=headers)
    with open(path, mode='wb') as f:
        f.write(response.content)

for page in range(100, 123):
    url = 'https://sj.qq.com/myapp/category.htm?orgame=1&categoryId={}'.format(page)
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
    }
    response = requests.get(url=url, headers=headers)
    selector = parsel.Selector(response.text)
    lis = selector.css('.main ul li')
    for li in lis:
        title = li.css('.app-info-desc a:nth-child(1)::text').get()
        apk_url = li.css('.app-info-desc a:nth-child(4)::attr(ex_url)').get()
        print(title, apk_url)
        download(apk_url, title)
Copy the code

Complete project has packaged code and other tools are available! Click here to get