存在,拿到src中的视频地址即可下载;https://m3api.awenhao.com/index.php?note=kkRq89j3mnaxf2bgp1sk5&raw=1&n.m3u8
https://m3api.awenhao.com/index.php?note=kkRpk9hzr2ay6g75et8nd&raw=1&n.m3u8
note是服务端生成随机码,且具有过期时间;
所以需要先爬取页面源码,再正则筛选生成的m3u8接口url;
import requests
import os
# 正则匹配
re_obj = re.compile(r"url: '(?P.*?)'," , re.S)
url = 'https://91kanju.com/vod-play/60608-1-1.html'
res1 = requests.get(url, headers=headers)
m3u8_url = re_obj.search(res.text).group('url')
res1.close()
# 下载m3u8文件
if not os.path.exists('./m3u8D'):
os.mkdir('./m3u8D')
res2 = requests.get(url=m3u8_url, headers=headers)
with open('./m3u8D/名侦探柯南.m3u8', 'wb') as f:
f.write(res2.content)
res2.close()
def get_url():
urls = []
with open('./m3u8D/名侦探柯南.m3u8', 'r', encoding='utf-8') as f:
for line in f:
# 去掉空格,换行符
line = line.strip()
# 去掉以#开头的行
if line.startswith('#'):
continue
urls.append(line)
return urls
def task(url, n):
res3 = requests.get(url=url,headers=headers)
with open('./m3u8D/%s.ts' % n, 'wb') as f:
f.write(res3.content)
if __name__ == '__main__':
url_list = get_url()
with ThreadPoolExecutor(30) as t:
for n, url in enumerate(url_list):
t.submit(task,url=url,n=n)
print('ok')