马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
亲测有效!!!
基础版的,没开线程,第一次爬电影,所以就凑合着用
import requests
import parsel
from ffmpy3 import FFmpeg
import os
target = "http://okzyw.com"
search = "http://okzyw.com/index.php?m=vod-search"
keys = "西部世界第一季" #神剧(最爱)
#keys里面的影片名称可以随便换,实测都能下载,建议影片名最好详细一点
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3775.400 QQBrowser/10.6.4208.400'
}
paramet = {
"m": "vod-search"
}
Datas = {
'wd': keys,
"submit": "search"
}
res = requests.post(url=search,params=paramet,data=Datas).text
html = parsel.Selector(res)
#提取内容页链接
link = html.xpath('//span[@class="xing_vb4"]/a/@href').get()
links = target + link
url = requests.get(url=links,headers=headers).text
content = parsel.Selector(url)
#抓取播放地址
contents = content.xpath('//ul/li/input/@value').getall()
#提取影片名称
names = content.xpath('//div[@class="vodh"]/h2/text()').get()
text_name = names
if names not in os.listdir('./'):
os.mkdir(names)
#print(names)
num = 1
for each in contents:
if "m3u8" in each:
print("=============================开始下载<%s>第%d集==============================="%(keys,num))
print(each)
#开始下载
t_name = os.path.join(text_name, "第%d集.mp4" %num)
FFmpeg(inputs={each:None},outputs={t_name:None}).run()
num += 1
|