像iqiyi這種視頻網站,現在下載視頻都需要下載相應的客戶端。那么如何不用下載客戶端,直接下載非vip視頻?

選擇你想要爬取的內容
該安裝的程序以及運行環境都配置好
下面這段代碼就是我在愛奇藝里搜素“英文名”,然后出來的視頻,共有20頁,那么我們便從第一頁開始,解析網頁,然后分析
分析每一頁網址,找出規律就可以直接得到所有頁面
然后根據每一個視頻的URL的標簽,如'class' 'div' 'href'......通過bs4庫進行爬取
而其他的信息則是直接循環所爬取到的URL,在每一個里再通過標簽去找
import requests
import pandas as pd
from bs4 import BeautifulSoup
#爬取URL
headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36'}
b=[]
for i in range(1,2):
url="https://so.iqiyi.com/so/q_英文名_ctg_t_0_page_"+str(i)+"_p_1_qc_0_rd__site__m_1_bitrate_" #共20頁,根據每頁的網址變換規律進行拼接
r=requests.get(url,headers=headers)
soup=BeautifulSoup(r.text,"html.parser")
a=soup.findAll('a',{'class':'main-tit'})
for i in a:
if 'http://www.'in i.get('href')and 'html'in i.get('href'):
b.append(i.get('href'))
print(b)
#爬取標題
e=[]
for k in b:
res=requests.get(k,headers=headers)
Soup=BeautifulSoup(res.text,'html.parser')
c=Soup.findAll('div',{'class':'feed-title-box'})
for d in c:
e.append(d.find('h2').text)
print(e)
#爬取標題下方描述
f=[]
for j in b:
res=requests.get(j,headers=headers)
Soup=BeautifulSoup(res.text,'html.parser')
c=Soup.findAll('div',{'class':'qy-play-intro-feed'})
for d in c:
f.append(d.find('p',{'class':"intro-iterm__block"}).text)
print(f)
#爬取發布時間
h=[]
for j in b:
res=requests.get(j,headers=headers)
Soup=BeautifulSoup(res.text,'html.parser')
c=Soup.findAll('div',{'class':'intro-iterm'})
for d in c:
ff=(d.find('span',{'class':"intro-iterm__txt"}))
if ff==None:
continue
h.append(ff.text)
print(h)
# 爬取上傳作者
m=[]
for k in b:
res=requests.get(k,headers=headers)
Soup=BeautifulSoup(res.text,'html.parser')
c=Soup.find('div',{'id':'block-P'})
d=Soup.find('div',{'class':'qy-player-maker'})
try:
name=c.get(':uploader').split(',')[1].split(':')[1].replace('"','')#輸出是字符串的格式,所以用split切割。replace替換
except:
try:
name=d.get(':uploader').split(',')[1].split(':')[1].replace('"','')
except:
m.append("匿名用戶")
m.append(name)
print(m)
文章題目:基于Python爬取愛奇藝資源過程解析-創新互聯
路徑分享:http://www.yijiale78.com/article20/deoico.html
成都網站建設公司_創新互聯,為您提供響應式網站、移動網站建設、商城網站、動態網站、自適應網站、外貿建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯