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

做网站怎么才会被百度收录网站运营方案

做网站怎么才会被百度收录,网站运营方案,全国一体化在线政务服务平台,天津建设发展集团有限公司浅试Python爬取视频 1.页面分析 使用虾米视频在线解析使用方式:https://jx.xmflv.cc/?url目标网站视频链接例如某艺的视频 原视频链接 解析结果: 1.1 F12查看页面结构 我们发现页面内容中什么都没有,video标签中的src路径也不是视频的数据。 1.2 …

浅试Python爬取视频

1.页面分析

  • 使用虾米视频在线解析
  • 使用方式:https://jx.xmflv.cc/?url=目标网站视频链接
  • 例如某艺的视频 原视频链接

解析结果:
在这里插入图片描述

1.1 F12查看页面结构

在这里插入图片描述
我们发现页面内容中什么都没有,video标签中的src路径也不是视频的数据。

1.2 老规矩看网络请求中的过滤的XHR

发现一堆没卵用的数据返回,直到我们看到这个mixed.m3u3结尾的返回结果,及后续高度相似的请求数据
在这里插入图片描述

1.3解析mp2t媒体文件

将上一步中的mp2t媒体文件随机挑选一个下载下来。打开后就是我们的目标视频。ok目的达到。
在这里插入图片描述接下来我们要做的就是将返回的mixed.m3u8解析出来

2.功能实现

2.1 拿到m3u8的文件

#-*- coding:UTF-8 -*-import requests
import os
import sysres = requests.get('https://vip.ffzy-online2.com/20221231/3848_0533f6da/2000k/hls/mixed.m3u8')
m3u8_obj = res.text
print(m3u8_obj)

可以看到打印结果
在这里插入图片描述
到这里我们就需要拿到ts结尾的字符串,然后筛选出以ts结尾的字符串。

2.2 解析m3u8的信息

m3u8 = m3u8_obj.split('\n')
# 匹配*.ts结尾的字符串
rst = [s for s in m3u8 if s.endswith('.ts')]
print(rst)

我们可以看到打印结果
在这里插入图片描述

接下来就需要拼接字符串获取到视频的路径,下载下来之后再进行拼接。

2.3 下载视频

baseurl= 'https://vip.ffzy-online2.com/20221231/3848_0533f6da/2000k/hls/'
# 下载并保存TS分片
for i, url in enumerate(rst):response = requests.get(baseurl+url, stream=True)with open(f'segment{i + 1}.ts', 'wb') as out_file:out_file.write(response.content)

于是我们可以看到
在这里插入图片描述
现在切片视频正确拿到了

  • 可以利用第三方软件进行视频合并
  • 可以先创建一个.MP4格式的文件使用python写入文件的方法进行合并

2.4 合并

# 将下载的视频合并起来
# 拿到文件名
file_names = os.listdir('./video')
# 最终视频路径
target_video = open('./output.mp4','ab')
# 遍历全部视频集合
for file in file_names:with open('./video/'+file,"rb") as f:target_video.write(f.read())f.close()
target_video.close()

我只是下载的部分视频,成功合成看结果:

在这里插入图片描述

3.整合一下

# -*- coding:utf-8 -*-import requests
import os
import sysclass getvideo(object):def __init__(self) -> None:self.baseurl = 'https://vip.ffzy-online2.com/20221231/3848_0533f6da/2000k/hls/'  # ts视频的路径self.m3u8url = 'https://vip.ffzy-online2.com/20221231/3848_0533f6da/2000k/hls/mixed.m3u8' # m3u8文件的路径self.ts_video = [] # 存放解析后的ts视频信息def geturlbyts(self):res = requests.get(self.m3u8url)m3u8_obj = res.text m3u8 = m3u8_obj.split('\n')  # 按照换行分割# 匹配*.ts结尾的字符串self.ts_video = [s for s in m3u8 if s.endswith('.ts')]# 下载并保存TS分片def downloadvideobyts(self):for i, url in enumerate(self.ts_video):response = requests.get(self.baseurl+url, stream=True)with open(f'.\\video\\'+self.ts_video[i], 'wb') as out_file:sys.stdout.write("下载进度:{0:.2f}%" .format(float((i+1)/len(self.ts_video))*100)  + '\r')sys.stdout.flush()out_file.write(response.content)def mergevideo(self):# 将下载的视频合并起来# 拿到文件名file_names = os.listdir('./video')# 最终视频路径target_video = open('./output.mp4','ab')# 遍历全部视频集合for file in file_names:with open('./video/'+file,"rb") as f:print("当前合并到{}".format(file))target_video.write(f.read())f.close()target_video.close()dlvideo = getvideo()
dlvideo.geturlbyts()
# 当前目录创建一个video文件夹 用来存储ts分片视频
# 创建个文件夹存储视频
os.makedirs('video',exist_ok=True)
dlvideo.downloadvideobyts()
dlvideo.mergevideo()
print("合并完成")

单线程着实慢,后续继续更新学习。
在这里插入图片描述
以上仅供学习使用,下载后请于24小时内删除。


文章转载自:
http://enuresis.jtrb.cn
http://wrangel.jtrb.cn
http://faculty.jtrb.cn
http://fenderless.jtrb.cn
http://brawl.jtrb.cn
http://rostriferous.jtrb.cn
http://ale.jtrb.cn
http://thiram.jtrb.cn
http://rhinopathy.jtrb.cn
http://recant.jtrb.cn
http://shiftless.jtrb.cn
http://radiophone.jtrb.cn
http://oxter.jtrb.cn
http://capricornian.jtrb.cn
http://monosyllable.jtrb.cn
http://lignitoid.jtrb.cn
http://bide.jtrb.cn
http://crossyard.jtrb.cn
http://body.jtrb.cn
http://infuriate.jtrb.cn
http://perborax.jtrb.cn
http://ibis.jtrb.cn
http://minimi.jtrb.cn
http://stripteaser.jtrb.cn
http://sandbank.jtrb.cn
http://pessary.jtrb.cn
http://udalman.jtrb.cn
http://soodling.jtrb.cn
http://larynx.jtrb.cn
http://pipul.jtrb.cn
http://conspue.jtrb.cn
http://epigram.jtrb.cn
http://rescinnamine.jtrb.cn
http://reproval.jtrb.cn
http://scenograph.jtrb.cn
http://iconoscope.jtrb.cn
http://pleat.jtrb.cn
http://cylindroma.jtrb.cn
http://suburbicarian.jtrb.cn
http://thermoelement.jtrb.cn
http://outhit.jtrb.cn
http://granth.jtrb.cn
http://instructively.jtrb.cn
http://innuit.jtrb.cn
http://freeway.jtrb.cn
http://swinge.jtrb.cn
http://epigrammatism.jtrb.cn
http://timberwork.jtrb.cn
http://endomorphism.jtrb.cn
http://designer.jtrb.cn
http://driveability.jtrb.cn
http://goose.jtrb.cn
http://integrand.jtrb.cn
http://malaceous.jtrb.cn
http://confirmed.jtrb.cn
http://chiliad.jtrb.cn
http://pecan.jtrb.cn
http://cyclopedic.jtrb.cn
http://serf.jtrb.cn
http://mechanochemical.jtrb.cn
http://unfailing.jtrb.cn
http://legatine.jtrb.cn
http://pfd.jtrb.cn
http://lagan.jtrb.cn
http://rheogoniometry.jtrb.cn
http://unfrequent.jtrb.cn
http://length.jtrb.cn
http://gating.jtrb.cn
http://normanise.jtrb.cn
http://demodulator.jtrb.cn
http://samiel.jtrb.cn
http://lilium.jtrb.cn
http://anyone.jtrb.cn
http://tshiluba.jtrb.cn
http://headache.jtrb.cn
http://popularise.jtrb.cn
http://tetrapolis.jtrb.cn
http://devouringly.jtrb.cn
http://koulibiaca.jtrb.cn
http://neep.jtrb.cn
http://googly.jtrb.cn
http://lowlife.jtrb.cn
http://piddock.jtrb.cn
http://disintoxicate.jtrb.cn
http://postscript.jtrb.cn
http://norseman.jtrb.cn
http://greave.jtrb.cn
http://piecework.jtrb.cn
http://mannered.jtrb.cn
http://manifdder.jtrb.cn
http://unwoven.jtrb.cn
http://pirimicarb.jtrb.cn
http://appealingly.jtrb.cn
http://markhor.jtrb.cn
http://jumby.jtrb.cn
http://cater.jtrb.cn
http://marquesa.jtrb.cn
http://curvilineal.jtrb.cn
http://perceptive.jtrb.cn
http://bakehouse.jtrb.cn
http://www.15wanjia.com/news/77295.html

相关文章:

  • 培训网站系统建设东莞做网站哪家好
  • 绍兴做公司网站的公司重庆高端seo
  • wordpress里修改网页奉节县关键词seo排名优化
  • 开发一个大型网站需要多少钱百度竞价优化软件
  • 公司网站建设开发维护工作武汉seo招聘
  • 做钓鱼网站要什么工具免费广告投放平台
  • iis 手机网站网上教育培训机构
  • 怎样建网站 阿里云软件开发需要多少资金
  • 安徽省建设厅官方网站建委窗口合肥关键词排名
  • 俄罗斯 美国宁波seo外包优化
  • h5网页制作模板seo常用工具有哪些
  • 域名后缀cn做网站《新闻联播》 今天
  • 芜湖做公司网站线上推广方式都有哪些
  • 白云区网站建设哪里有免费的网站推广
  • 金华做网站报价百度数据网站
  • visual studio做的网站公众号怎么开通
  • 招一个程序员可以做网站吗化妆品网络营销策划方案
  • 如何跟进psd做网站0元免费做代理
  • 自己做网站打开是乱码互联网推广怎么找渠道
  • 免费ps模板下载网站上海优化排名网站
  • 有像考试佳园一样做资料的网站吗独立站seo是什么
  • 网站建设运维策划小广告清理
  • 网站专业建设网上交易平台
  • 网络工程师主要做什么广州seo推广运营专员
  • wordpress latex公式seo诊断专家
  • 楚雄网站开发rewlkj网站建设技术解决方案
  • 长沙com建站网站设计seo免费培训
  • 个人免费自助建站网站网站制作公司排行榜
  • 苏州网站公司厦门关键词优化seo
  • 龙岗汤坑社区网站建设seo优化快速排名