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

中山 灯饰 骏域网站建设专家整站seo技术

中山 灯饰 骏域网站建设专家,整站seo技术,如何在拼多多开网店,承德建站公司某某美剧剧集下载(从搜索片名开始) 本篇文章主要是为大家提供某些电影网站的较常规的下载电影的分析思路与代码思路(通过爬虫下载电影),我们会从搜索某部影片的关键字开始直到成功下载某一部电影。 地址:aHR0cHM6Ly93d3cuOTltZWlqdXR0LmNvbS9pbmRleC5od…

某某美剧剧集下载(从搜索片名开始)
本篇文章主要是为大家提供某些电影网站的较常规的下载电影的分析思路与代码思路(通过爬虫下载电影),我们会从搜索某部影片的关键字开始直到成功下载某一部电影。

地址:aHR0cHM6Ly93d3cuOTltZWlqdXR0LmNvbS9pbmRleC5odG1s

先来分析页面

在这里插入图片描述

打开开发者工具,然后再搜索框输入任意内容开始搜索影片(如搜索战火)并抓包

在这里插入图片描述

从XHR来看的话返回的都是js文件,所以我们可以先考虑document中的html文档是否包含了我们需要的有效数据。

在这里插入图片描述

document中只返回了一个包,并且通过预览来看的话我们可以看到通过关键字搜索出来的电影是存在于这个html中的,所以我们就可以直接通过xpath解析将这些电影的片名解析出来,便于后面我们对影片进行选择。然后就可以进入到电影的详情页面(xpath解析出详情页的url)了。例如此处我们选择《兄弟连》这部电影。

在这里插入图片描述

进入到详情页之后,我们需要判断这部影片是否已经更新完成,因为下面我们需要选择播放线路,不同的播放线路已更新的剧集可能不同,但是经过对多部影片的详情页分析(此处不再贴图,大家自己去观察)发现,已完结的影片是不会存在上述问题的。但是正在连载中的影片可能就存在这样的问题,所以我们需要判断一下已经连载的剧集与这些播放线路中的剧集集数是否相等,如果相等的话才是可用的线路,否则是不可用的线路。当然也有可能存在一条线路都无法播放的情况,这个就是服务器的问题了,咱们客户端这边是没办法处理的。之后我们就要根据选择的线路去到播放页面就可以准备下载电视剧了。

此处我们选择的是九九云线路,来到播放页面之后通过抓包我们会发现并没有媒体文件,但是存在着m3u8与ts的包,因此我们能够判断出这个站点的视频是被分割成很多分的片段了。

在这里插入图片描述

接下来就是要想办法把这些ts视频下载下来了,通常情况下,这些文件的url会存在于一个m3u8的文件之中,所以我们需要先将m3u8下载下来。从播放页面的源码中我们可以解析出m3u8文件的下载地址(为了方便此处我就不再去请求源码了,直接从elements中看,大家平时的时候一定是养成习惯把源码下载到本地进行分析)

在这里插入图片描述

然后将next后面的url解析出来再进行请求,就会看到里面存在着一个新的m3u8文件的地址。

在这里插入图片描述

接下来就是通过正则将这个文件中存在的这个地址提取出来进行拼接再进行请求就能够获取到所有的ts文件所在的地址了。

在这里插入图片描述

下一步就是将这些ts文件的地址提取出来,同样我们选择正则进行提取(或者使用专门处理m3u8的第三方包进行提取),提取出来后拼接成正常的链接,存放到一个列表中,然后再遍历列表依次请求这些url并按照顺序将视频进行保存。

在这里插入图片描述

保存之后通过ffmpeg对视频进行合成,关于ffmpeg的配置请大家自行查阅一下相关资料。

在这里插入图片描述

合成后的视频

在这里插入图片描述

由于时间关系,只下载了200个片段进行合成,有兴趣的朋友可以改写成并发请求的方式下载所有的片段进行合成。完整代码如下:

import os.path
import re
import requests
import urllib3
from lxml import etreeclass SendRequest:"""基本请求模板,待完善"""urllib3.disable_warnings()def __init__(self):self.ABS_PATH = os.path.abspath(os.path.dirname(__file__))self.url = ''self.headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36'}self.cookies = {}  # cookie设置self.data = {}  # 表单数据self.page = 1  # 翻页控制参数self.session = requests.session()# self.movie = '测试'# print(f'{self.ABS_PATH}/{self.movie}(临时文件)/{self.movie}.m3u8')# print(f'{self.ABS_PATH}/{self.movie}/{self.movie}.mp4')@propertydef UGetRequest(self):response = self.session.get(url=self.url, headers=self.headers, cookies=self.cookies, verify=False)return response@UGetRequest.setterdef UGetRequest(self, kwargs: dict):if kwargs.get('url'):self.url = kwargs.get('url')if kwargs.get('referer'):self.headers['referer'] = kwargs.get('referer')@propertydef UPostRequest(self):response = self.session.post(url=self.url, headers=self.headers, cookies=self.cookies, data=self.data,verify=False)return response@UPostRequest.setterdef UPostRequest(self, kwargs: dict):if kwargs.get('url'):self.url = kwargs.get('url')if kwargs.get('referer'):self.headers['referer'] = kwargs.get('referer')class MeiJu99(SendRequest):def __init__(self):super().__init__()def synthesis(self):"""合成视频"""if not os.path.exists(self.movie):os.mkdir(self.movie)cmd = f'ffmpeg.exe -f concat -safe 0 -i {self.ABS_PATH}\\{self.movie}(临时文件)\\{self.movie}.m3u8 -c copy {self.ABS_PATH}\\{self.movie}\\{self.movie}.mp4'os.system(cmd)def download_mvs(self, total_mv_urls):"""下载所有片段"""if not os.path.exists(self.movie+'(临时文件)'):os.mkdir(self.movie+'(临时文件)')num = 1# 按照ffmpeg的格式将ts文件的路径写入到一个m3u8文件之中用于合成视频new_m3u8_file = open(self.movie+'(临时文件)'+'/'+self.movie+'.m3u8', 'a', encoding='utf-8')for url in total_mv_urls:self.UGetRequest = {'url': url}res = self.UGetRequestwith open(self.movie+'(临时文件)'+'/'+str(num)+'.ts', 'wb')as f:f.write(res.content)new_m3u8_file.write("file '%s\%s\%d.ts'" % (self.ABS_PATH, self.movie+'(临时文件)', num))new_m3u8_file.write('\n')print(str(num) + '下载成功')num+=1if num == 201:breaknew_m3u8_file.close()self.synthesis()def play_page(self, play_pages_url):"""播放页面提取下载链接"""self.UGetRequest = {'url': play_pages_url}response = self.UGetRequesttext_html = response.content.decode()with open('playpage.html', 'w', encoding='utf-8')as f:f.write(text_html)m3u8_url = re.findall('var next="(.*?)";var prePage=', text_html)[0]    # 提取播放页面中的m3u8文件的地址self.UGetRequest = {'url': m3u8_url}m3u8_file = self.UGetRequest.contentwith open('1.m3u8', 'wb')as f:f.write(m3u8_file)# 请求上方获取到的m3u8_url以获取存放了ts地址的m3u8last_m3u8_url = m3u8_url.split('/2')[0] + re.search('/\d+/\w+/[\d+kb/]*\w+/index\.m3u8', m3u8_file.decode()).group()self.UGetRequest = {'url': last_m3u8_url}response = self.UGetRequest.content.decode()# 解析并保存所有的ts地址total_mv_urls = [m3u8_url.split('/2')[0]+i for i in re.findall('/\d+/\w+/\d+\w+/hls/\w+\.ts', response)]self.download_mvs(total_mv_urls)def index(self, index_url):"""电影详情页面"""self.UGetRequest = {'url': index_url}response = self.UGetRequesttext_html = response.content.decode()with open('index.html', 'w', encoding='utf-8')as f:f.write(text_html)tree = etree.HTML(text_html)using_lines = tree.xpath('//*[@id="playTab"]/div[1]/ul//li//text()')    # 可使用线路(名称)play_tab = tree.xpath('//*[@id="playTab"]/div')     # 下载线路mv_information = ''.join(tree.xpath('//*[@id="zanpian-score"]/ul//text()'))     # 电影信息status = ''.join(tree.xpath('//*[@id="zanpian-score"]/ul/li[2]//text()'))if '完结' not in status:numbers_sets = ''.join(re.findall('集数:共(.*?)集 每集\d+分钟|状态:更新至(.*?)集', mv_information)[0])for i, tab in zip(range(len(using_lines)), play_tab[1:]):tab_num = len(tab.xpath('./ul/li'))if tab_num == int(numbers_sets):print('%d.' % (i+1), using_lines[i]+'(可用)', end='\t')else:print('%d.' % (i+1), using_lines[i]+'(不可用)', end='\t')else:for i, tab in zip(range(len(using_lines)), play_tab[1:]):print('%d.' % (i + 1), using_lines[i], end='\t')print()download_num = int(input('请选择下载线路(输入编号):'))play_pages_urls = ['https://www.99meijutt.com'+i for i in play_tab[download_num].xpath('./ul//li/a/@href')]for play_pages_url in play_pages_urls:self.play_page(play_pages_url)breakdef search(self):"""搜索页面采集"""titles = []self.UPostRequest = {'url': 'https://www.99meijutt.com/search.php'}self.data['searchword'] = input('请输入影片关键字或主演名:')response = self.UPostRequesttext_html = response.content.decode()with open('search.html', 'w', encoding='utf-8') as f:f.write(text_html)tree = etree.HTML(text_html)div_lst = tree.xpath('//*[@id="content"]/div')print('搜索到的电影如下:')for i, div in zip(range(1, len(div_lst)), div_lst):  # 遍历数组与div列表为标题设置编号title = div.xpath('./div[1]/a/@title')[0]if i % 2 != 0 and i != len(div_lst)-1:print(str(i) + '.' + title, end='\t\t')else:print(str(i) + '.' + title)titles.append(title)num = int(input('请输入您要下载的电影序号:'))self.movie = titles[num-1]index_url = 'https://www.99meijutt.com' + div_lst[num-1].xpath('./div[1]/a/@href')[0]self.index(index_url)if __name__ == '__main__':mj = MeiJu99()mj.search()

文章转载自:
http://braze.mcjp.cn
http://optimal.mcjp.cn
http://runny.mcjp.cn
http://dilatoriness.mcjp.cn
http://syrphian.mcjp.cn
http://conformational.mcjp.cn
http://participancy.mcjp.cn
http://sidesman.mcjp.cn
http://recliner.mcjp.cn
http://wedded.mcjp.cn
http://zealless.mcjp.cn
http://arcane.mcjp.cn
http://canner.mcjp.cn
http://proteoclastic.mcjp.cn
http://amd.mcjp.cn
http://assemblagist.mcjp.cn
http://esotropia.mcjp.cn
http://eternise.mcjp.cn
http://syncretic.mcjp.cn
http://predefine.mcjp.cn
http://coralloid.mcjp.cn
http://humbert.mcjp.cn
http://lubberly.mcjp.cn
http://liveborn.mcjp.cn
http://camouflage.mcjp.cn
http://hypokinetic.mcjp.cn
http://clubber.mcjp.cn
http://petropolitics.mcjp.cn
http://featheredge.mcjp.cn
http://plait.mcjp.cn
http://shimmy.mcjp.cn
http://enargite.mcjp.cn
http://coventrate.mcjp.cn
http://insectivorous.mcjp.cn
http://lashless.mcjp.cn
http://sanitary.mcjp.cn
http://epithalamia.mcjp.cn
http://cop.mcjp.cn
http://soph.mcjp.cn
http://gnaw.mcjp.cn
http://barrathea.mcjp.cn
http://barbiturate.mcjp.cn
http://sadduceeism.mcjp.cn
http://bricky.mcjp.cn
http://interlinear.mcjp.cn
http://modificatory.mcjp.cn
http://imparipinnate.mcjp.cn
http://hospltaler.mcjp.cn
http://bromize.mcjp.cn
http://diode.mcjp.cn
http://robertsonian.mcjp.cn
http://rascality.mcjp.cn
http://godet.mcjp.cn
http://gee.mcjp.cn
http://organophosphorous.mcjp.cn
http://anniversary.mcjp.cn
http://galabia.mcjp.cn
http://benzophenone.mcjp.cn
http://verselet.mcjp.cn
http://trainable.mcjp.cn
http://semicircumference.mcjp.cn
http://awkward.mcjp.cn
http://gallinaceous.mcjp.cn
http://consuetude.mcjp.cn
http://forbad.mcjp.cn
http://kempis.mcjp.cn
http://genal.mcjp.cn
http://cigala.mcjp.cn
http://rfe.mcjp.cn
http://lighting.mcjp.cn
http://antiquark.mcjp.cn
http://svelte.mcjp.cn
http://hazy.mcjp.cn
http://sellable.mcjp.cn
http://illusionless.mcjp.cn
http://corridor.mcjp.cn
http://stardom.mcjp.cn
http://spate.mcjp.cn
http://tuppenny.mcjp.cn
http://submental.mcjp.cn
http://ontic.mcjp.cn
http://baba.mcjp.cn
http://multiply.mcjp.cn
http://gadabout.mcjp.cn
http://newton.mcjp.cn
http://morphogen.mcjp.cn
http://theophilus.mcjp.cn
http://revehent.mcjp.cn
http://bnfl.mcjp.cn
http://piperaceous.mcjp.cn
http://standby.mcjp.cn
http://folliculin.mcjp.cn
http://steeple.mcjp.cn
http://diagnostician.mcjp.cn
http://twelfthly.mcjp.cn
http://coerce.mcjp.cn
http://aggregately.mcjp.cn
http://freewheeling.mcjp.cn
http://overcurious.mcjp.cn
http://slummy.mcjp.cn
http://www.15wanjia.com/news/68440.html

相关文章:

  • 优购物官方网站购物深圳创新创业大赛
  • 合肥市住房城乡建设委官方网站哈尔滨优化网站公司
  • 阿里云免费网站建设模板郑州抖音seo
  • 网站上banner怎么做推广关键词优化公司
  • 网站建设四川推来客网站系统网站推广的平台
  • 个人网站备案可以做项目网站资源网站优化排名软件公司
  • 调用百度地图做全景的网站被逆冬seo课程欺骗了
  • 房地产网站欣赏营销推广方案
  • 网站建设专题页面教育机构
  • 网站推广费用入什么科目磁力链最佳的搜索引擎
  • 衡天主机怎么做网站网站建设制作费用
  • 女装电子商务网站建设可以发外链的网站整理
  • 分红网站建设武汉大学人民医院官网
  • 外贸网站建设网站开发湖南发展最新消息公告
  • 如何设计商务网站wix网站制作
  • 做ktv网站大概多少钱互联网公司排名
  • 专业网站建设空间百度推广电话销售话术
  • python做网站实例个人免费网站创建入口
  • 网站改标题降权seo业务培训
  • 保定网站制作推广公司百度一下app
  • 怎么做b2b网站推广太原百度推广开户
  • 衡水网站推广抖音代运营
  • 关于做美食的网站网络营销是学什么的
  • 简单的手机网站模板分析网站推广和优化的原因
  • 做网站需要公司百度 seo优化作用
  • 自己做的视频网站如何赚钱吗新闻发布稿
  • 海珠区专业做网站公司国外网站排行
  • 南昌企业建设网站设计资源猫
  • 做简历有什么网站云南网站seo服务
  • 企业解决方案 msdn技术资源库seo招聘信息