前言
本文的文字及圖片來源于網路,僅供學習、交流使用,不具有任何商業用途,如有問題請及時聯系我們以作處理,
基本環境配置
- python 3.6
- pycharm
- requests
- parsel
打開開發者工具分析網頁
你怎么知道這個就是下載地址呢?
1、選擇一個應用的下載地址
2、打開開發者工具,清空資料,選擇Network
3、點擊立即下載
4、就會發現下載地址
把鏈接地址復制,在網頁源代碼中搜索,查看是否網頁是否有回傳該資料
- 有資料: 就可以直接請求網頁獲取地址;
- 沒有資料: 那就要在開發這工具里面找是否有介面資料,然后一步一步在進行分析;
實作效果
完整代碼
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)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/142372.html
標籤:其他
上一篇:Java 多執行緒并發編程
