任务需求:
- 网站地址:https://v.qq.com/x/cover/ehqo76prcwku2oq/x0032rq56lh.html
- 使用的库 multiprocessing,requests
- 主要技术点:
- 使用全民解析分析.ts文件
- 使用命令行 cat *.ts>hebing.ts 合成ts视频文件(mac电脑命令行)
# -*- coding: utf-8 -*-
# @Time : 2020/7/29 6:05 下午
# @Author : livein80
# @Email : 12985594@qq.com
# @File : ssyer.py
# @Software : PyCharm
# https://vip.okokbo.com/20180319/FITtZ17w/1000kb/hls/OdGD6663072.ts
import requests
import os
from multiprocessing import Pool
headers={
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'
}
def download_vip(i):
url = 'https://vip.okokbo.com/20180319/FITtZ17w/1000kb/hls/OdGD6663%04d.ts' % i
# print(url)
res = requests.get(url,headers=headers).content
# 写入文件
with open('./movie/m_{}'.format(url[-7:]), 'wb') as file:
file.write(res)
print(url[-7:]+'写入成功')
if __name__=="__main__":
pool = Pool(15)
# 判断文件夹是否存在
if not os.path.exists('./movie/'):
os.mkdir('./movie/')
for i in range(1000,1400):
pool.apply_async(download_vip,args=(i,))
#关闭池
pool.close()
pool.join()
print("下载结束!")