python愛奇藝VIP視訊爬蟲爬取下載
我是跟著@Jack-Cui 老哥的部落格爬的,發現爬取的網站更新了,不得不跟著更新爬取的程式碼
原部落格:https://blog.csdn.net/c406495762/article/details/78123502
要點:1.charles抓包、分析、compose功能
2.淺複製 headers.copy()
3.re.findall 的用法
4.js的 encodeURIComponent 轉碼使用urllib parse.unquote
注:fiddler侷限性很大,tunnel to的網頁不能顯示,問了很多爬蟲前輩,加上百度,我用上了charles花瓶,挺好用的,大家可以自行研究下,得搞破解版才行哦!
###http://api.xfsub.com/index.php?url=http://www.iqiyi.com/v_19rr7qhfg0.html#vfrm=19-9-0-1
現在這個旋風破解又特麼更新了,不能直接播放,得搞個框架才行,非常麻煩
但我還是忍著噁心去解析了這個vip播放網站,到最後一步下載視訊時,居然更噁心!!
檔案居然是ts格式,還是幾百個!!每個5秒鐘,所以我做到這一步就不搞了,我把程式碼貼上來,大家可以看看思路
import requests,json,re from bs4 import BeautifulSoup from urllib import parse class download_movie(): def __init__(self,url): self.headers={'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36'} self.first_url='http://api.xfsub.com/index.php?url='+url.split('#')[0] self.main_ip='https://api.177537.com' def second_url(self): '''因為現在是用iframe框架,所以我搞多一步,返回的url就是 https://api.177537.com/?url= + http://www.iqiyi.com/v_19rrkqj6kg.html 偷懶應該可以直接上url就行了 headers的referer愛奇藝的應該是固定的字元url''' headers=self.headers.copy() if 'www.iqiyi.com' in self.first_url: headers['referer']='http://api.xfsub.com/index.php?url=http://www.iqiyi.com/v_19rr7qhfg0.html' req = requests.get(self.first_url, headers=headers) bf = BeautifulSoup(req.text, 'lxml') api_url = bf.find('iframe')['src'] return api_url def post_info(self): '''api_url=https://api.177537.com/?url=http://www.iqiyi.com/v_19rrkqj6kg.html 用正規表示式求出post的4個引數,求出來的是5個,實際只需要4個 headers的referer就是api.xfsub.com/index.php?url='+url''' api_url=self.second_url() headers = self.headers.copy() headers['referer'] =self.first_url req = requests.get(api_url, headers=headers) req_json = re.findall('"url.php", (.+),', req.text)[0] req1 = re.findall('(.+),"ckey1"', req_json)[0] + '}' info = json.loads(req1) return info def post_url(self): '''把那4個引數post到https://api.177537.com/url.php(好像是固定網站) 會返回包含電影地址的網站,不過要注意play這個引數,返回的url型別不同的!!''' info=self.post_info() data = {'time': info['time'], 'key': info['key'], 'url': info['url'], 'type': info['type']} req = requests.post(self.main_ip+'/url.php', headers=self.headers, data=data) url =json.loads(req.text)['url'] play=json.loads(req.text)['play'] return play,url def movie_url(self): '''play=m3u8時,url="http%3A%2F%2Fvs1.baduziyuan.com%2F%2Fppvod%2F42070A3BCA22609F4655BE87FAAC49F8.m3u8" 所以得用unquote轉碼 play=xml時,url=/url.php?key=357350013cc120d659b1a4d5e1d7acfe&time=1523979626&url=http%3A%2F%2Fwww.iqiyi.com%2Fv_19rrluypwg.html&type=iqiyi&xml=1 需要加頭才能get''' play,url=self.post_url() print(play,url) if play=='m3u8': url1=parse.unquote(url) self.m3u8_movie(url1) elif play=='xml': url1=self.main_ip+url self.xml_movie(url1) def xml_movie(self,url1): '''這種情況得到的是xml,電影片段零碎, 都是http://61.179.109.165/14/w/89aae12482708fc94010602ff1b34520.mp4?type=ppbox.launcher&key=a32e0dd656ea3cc2f31b98b102ce71c6&k=02ecf7808b8c478dca6b1a98cd4c595a-a396-1523991314', 每段都有7分鐘,幾十個檔案!!''' req = requests.get(url1, headers=self.headers) bf = BeautifulSoup(req.text, 'xml') # 因為檔案是xml格式的,所以要進行xml解析。 video_url = bf.find_all('file') urls = [] for ip in video_url: urls.append(ip.string) print(urls) def m3u8_movie(self,url1): '''這種情況得到的是text,電影片段很零碎,而且地址還得自己加頭, 都是/20180108/lf0jrQw6/800kb/hls/H1iYGK7412000.ts, 每段都只有幾秒,幾百個檔案,很噁心!!''' req = requests.get(url1, headers=self.headers) text=re.findall(r'(.+.ts)',req.text) head = re.findall('(^.+com)', url1)[0] urls=[] for path in text: urls.append(head+path) print(urls) url='http://www.iqiyi.com/v_19rrluypwg.html' text=download_movie(url) text.movie_url()
另外在說說Jack-Cui之前視訊破解的解析網站,還有個更好的,不需要搞iframe框架,直接就能看vip的,我用charles分析了下,大同小異,把圖片貼上來,如果有興趣,可以直接爬這個網站,不過到了最後一步,視訊檔案還是幾秒的,幾百個,下載還是算了吧!!
---------------------------------------
-------------------------------
----------------
不知為什麼,有2種格式或者播放的檔案,一個是7分鐘,一個是5秒鐘的,連結也完全不同
---------------------------
--------------------------
---------------------------------------
-------------------------
---------------------------------
要注意referer一定要有,不然打不開網頁,charles的compose功能很好用,大家可以研究下
相關文章
- Python爬蟲入門教程 50-100 Python3爬蟲爬取VIP視訊-Python爬蟲6操作Python爬蟲
- python網路爬蟲_Python爬蟲:30個小時搞定Python網路爬蟲視訊教程Python爬蟲
- 【Python學習】爬蟲爬蟲爬蟲爬蟲~Python爬蟲
- python爬蟲練習--爬取虎牙主播原畫視訊Python爬蟲
- Python爬蟲訓練:爬取酷燃網視訊資料Python爬蟲
- 新手寫的視訊爬蟲爬蟲
- 【python爬蟲】python爬蟲demoPython爬蟲
- python爬蟲---網頁爬蟲,圖片爬蟲,文章爬蟲,Python爬蟲爬取新聞網站新聞Python爬蟲網頁網站
- 如何爬取視訊的爬蟲程式碼原始碼爬蟲原始碼
- Python 爬蟲 目標:千圖網VIP高清無水印下載即用Python爬蟲
- python就是爬蟲嗎-python就是爬蟲嗎Python爬蟲
- Python爬蟲Python爬蟲
- python 爬蟲Python爬蟲
- Python爬取動態載入的視訊(梨視訊,xpath)Python
- Python爬蟲教程-01-爬蟲介紹Python爬蟲
- Java爬蟲與Python爬蟲的區別?Java爬蟲Python
- 實用爬蟲-03-爬取視訊教程課程名+連結+下載圖片爬蟲
- 如何用python爬蟲下載小說?Python爬蟲
- Python爬蟲入門學習線路圖2019最新版(附Python爬蟲視訊教程)Python爬蟲
- python爬蟲初探--第一個python爬蟲專案Python爬蟲
- 【python--爬蟲】彼岸圖網高清桌布爬蟲Python爬蟲
- 什麼是爬蟲?Python爬蟲框架有哪些?爬蟲Python框架
- 【爬蟲】python爬蟲從入門到放棄爬蟲Python
- Python爬蟲之路-chrome在爬蟲中的使用Python爬蟲Chrome
- Python爬蟲與Java爬蟲有何區別?Python爬蟲Java
- python爬蟲實戰,爬蟲之路,永無止境Python爬蟲
- Python爬蟲(1.爬蟲的基本概念)Python爬蟲
- 圖靈樣書爬蟲 - Python 爬蟲實戰圖靈爬蟲Python
- python 爬蟲 爬取 learnku 精華文章Python爬蟲
- python爬蟲——爬取大學排名資訊Python爬蟲
- Python asyncio 爬蟲Python爬蟲
- python爬蟲2Python爬蟲
- Python爬蟲——XPathPython爬蟲
- Python 爬蟲系列Python爬蟲
- Python爬蟲-xpathPython爬蟲
- Python爬蟲--2Python爬蟲
- 2個月精通Python爬蟲——3大爬蟲框架+6場實戰+反爬蟲技巧+分散式爬蟲Python爬蟲框架分散式
- 爬蟲:多程式爬蟲爬蟲