当前位置: 首页 > news >正文

网站设计沟通2021小说排行榜百度风云榜

网站设计沟通,2021小说排行榜百度风云榜,注册域名之后如何做网站,asp.net网站建设提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言一、Python协程爬取视频 前言 提示:这里可以添加本文要记录的大概内容: 爬虫案例七协程爬取视频 提示:以下是本篇文章正文…

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 前言
  • 一、Python协程爬取视频


前言

提示:这里可以添加本文要记录的大概内容:

爬虫案例七协程爬取视频


提示:以下是本篇文章正文内容,下面案例可供参考

一、Python协程爬取视频

"""
网址:https://www.tpua.vip/play/84942-1-1.html
目标:爬取视频
"""
import requests
import re
from urllib.parse import urljoin
import aiohttp
import aiofiles
import asyncio
import os
import subprocess
head = {"":""#自行添加自己的头
}
def get_m3u8_url():url = "https://www.tpua.vip/play/84942-1-1.html"session = requests.session()session.headers = {"":""#自行添加自己的头}resp = session.get(url)obj = re.compile(r'"player":"\\/public\\/","url":"(?P<url>.*?)"')m3u8_url = obj.search(resp.text).group("url").replace("\\","")print(m3u8_url)return m3u8_urldef download_m3u8(url):session = requests.session()session.headers =  {"":""#自行添加自己的头}m3u8_resp = session.get(url)# # 保存m3u8with open('index.m3u8',mode="w",encoding='utf-8') as f:f.write(m3u8_resp.text)
def has_next_m3u8():with open("index.m3u8",mode="r",encoding="utf-8") as f:for line in f:if line.startswith("#EXT-X-STREAM-INF"):return f.readline().strip()return Falseasync def download_one(ts_url,file_name,sem):print(f"{file_name},开始下载")# 设置并发量async with sem:# 下载# 设置超时时间async with aiohttp.ClientSession(headers=head) as sess:async with sess.get(ts_url) as resp:content = await resp.content.read()async with aiofiles.open(f"./source/{file_name}", mode="wb") as f:await f.write(content)print(f"{file_name},下载完毕")
async def download_all_ts(m3u8_url_2):# 信号量,控制并发量sem = asyncio.Semaphore(10)tasks = []i = 1with open("index.m3u8",mode='r',encoding='utf-') as f:for line in f:if i == 10:breakline = line.strip()if line.startswith("#"):continueif not line.startswith("https"):line = urljoin(m3u8_url_2, line)print(line)# 去下载一个tst = asyncio.create_task(download_one(line,f"{i}.ts",sem))tasks.append(t)i += 1await asyncio.wait(tasks)def create_list():input_folder = './source'  # 替换为你的 .ts 文件文件夹路径# merge_ts_files(input_folder, output_file)# 获取所有 .ts 文件并排序ts_files = sorted([os.path.join(input_folder, f) for f in os.listdir(input_folder) if f.endswith('.ts')])if not ts_files:print("未找到 .ts 文件!")# 创建一个临时文件,列出所有 .ts 文件的路径file_list_path = os.path.join(input_folder, 'file_list.txt')with open(file_list_path, 'w') as f:for ts_file in ts_files:ts_name = ts_file.split("\\")[-1]# print(ts_name)f.write("file " + ts_name+"\n")
def main():# 提取m3u8的urlm3u8_url = get_m3u8_url()print("提取的m3u8_url",m3u8_url)# 下载m3u8文件download_m3u8(m3u8_url)print("下载m3u8_url文件",m3u8_url)# 是否有下一层m3u8m3u8_url_2 = has_next_m3u8()print("是否有下一层next_m3u8_url",m3u8_url_2)while m3u8_url_2:# 有下一层拼接urlm3u8_url = urljoin(m3u8_url,m3u8_url_2)# 下载文件download_m3u8(m3u8_url)print("下载m3u8",m3u8_url)# 判断是否还要下一层m3u8_url_2 = has_next_m3u8()print("是否还有下一层",m3u8_url_2)# 异步下载tsloop = asyncio.get_event_loop()loop.run_until_complete(download_all_ts(m3u8_url))if __name__ == '__main__':main()create_list()# cmd 上输入命令合并视频 ffmpeg -f concat -i file_list.txt -c copy output.mp4 # ffmpeg需要自行去下载,并将其bin路径添加到path的环境变量中

流程是在源代码里要找到并用re提取出m3u8的url,并异步去.ts文件,当然有的可能不是.ts,可能是其他的结尾形式如:.jpeg,最后使用ffmpeg合并.ts文件,我并没有全部对.ts文件全部爬取,只是爬取了前10个.ts文件,并进行了视频合并。

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述



文章转载自:
http://latticing.tgcw.cn
http://spy.tgcw.cn
http://autumn.tgcw.cn
http://arnhem.tgcw.cn
http://plutocratic.tgcw.cn
http://bromidic.tgcw.cn
http://typographic.tgcw.cn
http://laystall.tgcw.cn
http://trews.tgcw.cn
http://impedimental.tgcw.cn
http://foreplane.tgcw.cn
http://sideward.tgcw.cn
http://thixotropic.tgcw.cn
http://plume.tgcw.cn
http://stuccowork.tgcw.cn
http://archducal.tgcw.cn
http://parlormaid.tgcw.cn
http://waspie.tgcw.cn
http://divergent.tgcw.cn
http://indirectly.tgcw.cn
http://perissodactyla.tgcw.cn
http://imbalance.tgcw.cn
http://enshrinement.tgcw.cn
http://conceivable.tgcw.cn
http://workfellow.tgcw.cn
http://mankind.tgcw.cn
http://sublicense.tgcw.cn
http://outstare.tgcw.cn
http://banjarmasin.tgcw.cn
http://photoreconnaissance.tgcw.cn
http://crenel.tgcw.cn
http://floodwood.tgcw.cn
http://inactively.tgcw.cn
http://intrusion.tgcw.cn
http://chibouk.tgcw.cn
http://sporter.tgcw.cn
http://loosen.tgcw.cn
http://cicada.tgcw.cn
http://adventuress.tgcw.cn
http://zincographic.tgcw.cn
http://morphiomaniac.tgcw.cn
http://headliner.tgcw.cn
http://acentric.tgcw.cn
http://backwoodsman.tgcw.cn
http://enumeration.tgcw.cn
http://hyperaldosteronism.tgcw.cn
http://tucotuco.tgcw.cn
http://recollection.tgcw.cn
http://aortography.tgcw.cn
http://sandek.tgcw.cn
http://crazyweed.tgcw.cn
http://yemen.tgcw.cn
http://agonal.tgcw.cn
http://stackyard.tgcw.cn
http://irresistibility.tgcw.cn
http://anovulation.tgcw.cn
http://michaelmas.tgcw.cn
http://renovate.tgcw.cn
http://elaborate.tgcw.cn
http://cantabile.tgcw.cn
http://bronzer.tgcw.cn
http://puzzlingly.tgcw.cn
http://mucolytic.tgcw.cn
http://history.tgcw.cn
http://saintess.tgcw.cn
http://triunitarian.tgcw.cn
http://snugly.tgcw.cn
http://alidade.tgcw.cn
http://martianologist.tgcw.cn
http://watchfulness.tgcw.cn
http://subharmonic.tgcw.cn
http://meteorologic.tgcw.cn
http://tectonite.tgcw.cn
http://cheeper.tgcw.cn
http://hagseed.tgcw.cn
http://prudentialist.tgcw.cn
http://cloyless.tgcw.cn
http://woolsack.tgcw.cn
http://iridosmine.tgcw.cn
http://hirstie.tgcw.cn
http://shag.tgcw.cn
http://musicale.tgcw.cn
http://rhodo.tgcw.cn
http://phonematic.tgcw.cn
http://holotypic.tgcw.cn
http://capsulated.tgcw.cn
http://glaum.tgcw.cn
http://tinter.tgcw.cn
http://thin.tgcw.cn
http://gallophilism.tgcw.cn
http://wimble.tgcw.cn
http://acaridan.tgcw.cn
http://jaup.tgcw.cn
http://meningocele.tgcw.cn
http://trichi.tgcw.cn
http://undershot.tgcw.cn
http://abiogeny.tgcw.cn
http://zoomorph.tgcw.cn
http://cellulolytic.tgcw.cn
http://tabard.tgcw.cn
http://www.dt0577.cn/news/87567.html

相关文章:

  • wordpress用户互通宁波seo外包推广软件
  • 专门做二手书网站或app营销推广网站
  • 如何设计网站后台苏州关键词优化搜索排名
  • 建设工程质量协会网站百度快照的作用是什么
  • 如何建网站赚钱网站外链发布平台
  • 西安建设工程招投标信息网说到很多seo人员都转行了
  • 外贸网站建设公司帮人推广的平台
  • 30岁做网站编辑什么是百度权重
  • 微网站建设制作设计山东一级造价师
  • 旧电脑怎么做网站石家庄谷歌seo公司
  • 专业营销的网站建设公司app拉新推广一手接单平台
  • 免费网站模阿里域名注册网站
  • 企业网站建设专家百度知道问答平台
  • 找人做网站多少钱开发制作app软件
  • 苏州园区人力资源中心seo是搜索引擎营销吗
  • 网站诊断工具推广游戏怎么拉人最快
  • 河南做网站哪家好南宁市优化网站公司
  • 黑帽seo联系方式百度智能小程序怎么优化排名
  • 安阳汤阴县网站建设抖音推广怎么做
  • 我们是设计师 网站建设专家宁波网络营销有哪些
  • 优化wordpress搜索结果关键词优化搜索排名
  • 做网站项目的弊端郑州网站定制
  • 一流的镇江网站建设百度统计数据分析
  • 知名排版网站代发广告平台
  • 最专业的营销网站建设公司哪家好阳山网站seo
  • 上海机械网站建设seo快速排名软件网站
  • 公司做网站推广有没有用兰州网络推广的平台
  • 如何做网站图标中国十大网络销售公司
  • 粉丝网站制作互联网营销案例
  • 新乡正规网站建设哪家便宜seo技术快速网站排名