检查腾讯视频更新情况
2295天前 · 分享 · python · 1102次阅读
检查腾讯视频最新集数
import re
import json
import requests
from bs4 import BeautifulSoup as bs
request库用于抓取网页
BeautifulSoup用于解析网页
json用于解析接口数据
url = "http://v.qq.com/zhuiju/?type=3"#1 2 3分别是电视剧 综艺 动漫
#url_text = requests.get(url).text
url_res = requests.get(url).content.decode("utf-8")
#print(url_res)
请求网页并解码
soup = bs(url_res, "lxml")
for area3 in soup.find_all("li",class_=re.compile("item area area")):
vid = area3.get("data-vid")
print("vid",vid)
print("首集链接",area3.a.get("href"))
detail = area3.a.get("href").replace("cover","detail")
print("详情页链接",detail)
title = re.sub('[[/\\\:*?"<>|]]','',area3.find("h3",class_="title").a.get_text()).replace(" ","_")
print("标题:{}".format(title))
up_flag = area3.find("em",class_="mark_inner")
if up_flag:
print(up_flag.get_text())
else:
print("暂未更新")
continue
get_playsource = "http://s.video.qq.com/get_playsource?id={}&plat=2&type=4&range=1&otype=json".format(vid)
print(get_playsource)
get_playsource_res = requests.get(get_playsource).content.decode("utf-8")
QZOutputJson = re.findall("QZOutputJson.*?({.*?});",get_playsource_res)[0]
show_num = 0
for _ in json.loads(QZOutputJson)["PlaylistItem"]["videoPlayList"]:
if _["type"] == "2":
continue
elif _["type"] == "1":
title = re.sub('[[/\\\:*?"<>|]]','',_["title"]).replace(" ","_")
print("集数:{} 标题:{} vid:{} 链接:{}".format(_["episode_number"],title,_["id"],_["playUrl"]))
else:
print("未知类型")
print(_)
show_num += 1
if show_num == 5:
break
#detail_res = requests.get(detail).content.decode("utf-8")
#soup_detail = bs(detail_res,"lxml")
#show_num = 0
#for _ in reversed(soup_detail.find_all("span",class_="item")):
# mark_flag = _.find("span",class_="mark_v")
# if mark_flag:
# episodeFlag = mark_flag.img.get("alt")
# else:
# episodeFlag = "normal"
# episodeNumber = _.find("span",{"itemprop":"episodeNumber"}).get_text()
# episodeUrl = _.find("a").get("href")
# print("集数",episodeNumber,"状态",episodeFlag,"链接",episodeUrl)
# show_num += 1
# if show_num == 5:
# break
#break
vid j18xzp93h4c1ofn
首集链接 http://v.qq.com/cover/j/j18xzp93h4c1ofn.html
详情页链接 http://v.qq.com/detail/j/j18xzp93h4c1ofn.html
标题:武庚纪_第2季
更新
http://s.video.qq.com/get_playsource?id=j18xzp93h4c1ofn&plat=2&type=4&range=1&otype=json
集数:34 标题:34_武庚纪_第2季_34 vid:k0027sfo0jd 链接:http://v.qq.com/x/cover/j18xzp93h4c1ofn.html?vid=k0027sfo0jd
集数:33 标题:33_武庚纪_第2季_33 vid:y0027znppbq 链接:http://v.qq.com/x/cover/j18xzp93h4c1ofn.html?vid=y0027znppbq
集数:32 标题:32_武庚纪_第2季_32 vid:k0027whmqlf 链接:http://v.qq.com/x/cover/j18xzp93h4c1ofn.html?vid=k0027whmqlf
集数:31 标题:31_武庚纪_第2季_31 vid:h00271uzu1d 链接:http://v.qq.com/x/cover/j18xzp93h4c1ofn.html?vid=h00271uzu1d
集数:30 标题:30_武庚纪_第2季_30 vid:m0026faffy2 链接:http://v.qq.com/x/cover/j18xzp93h4c1ofn.html?vid=m0026faffy2
vid kjketdv4sqxxuky
首集链接 http://v.qq.com/cover/k/kjketdv4sqxxuky.html
详情页链接 http://v.qq.com/detail/k/kjketdv4sqxxuky.html
标题:枪神记
更新
http://s.video.qq.com/get_playsource?id=kjketdv4sqxxuky&plat=2&type=4&range=1&otype=json
集数:22 标题:22_枪神记_22 vid:g0027i49eea 链接:http://v.qq.com/x/cover/kjketdv4sqxxuky.html?vid=g0027i49eea
集数:21 标题:21_枪神记_21 vid:x002729k1r7 链接:http://v.qq.com/x/cover/kjketdv4sqxxuky.html?vid=x002729k1r7
集数:20 标题:20_枪神记_20 vid:g00271ukpe7 链接:http://v.qq.com/x/cover/kjketdv4sqxxuky.html?vid=g00271ukpe7
集数:19 标题:19_枪神记_19 vid:n002759a6ub 链接:http://v.qq.com/x/cover/kjketdv4sqxxuky.html?vid=n002759a6ub
集数:18 标题:18_枪神记_18 vid:b0026wcl7hp 链接:http://v.qq.com/x/cover/kjketdv4sqxxuky.html?vid=b0026wcl7hp
vid wd7wvlekmeknnr6
首集链接 http://v.qq.com/cover/w/wd7wvlekmeknnr6.html
详情页链接 http://v.qq.com/detail/w/wd7wvlekmeknnr6.html
标题:画江湖之侠岚
更新
http://s.video.qq.com/get_playsource?id=wd7wvlekmeknnr6&plat=2&type=4&range=1&otype=json
集数:30 标题:30_第30集_盛炁之地 vid:v0751tqn093 链接:http://v.qq.com/x/cover/wd7wvlekmeknnr6.html?vid=v0751tqn093
集数:29 标题:29_第29集_亘古不变 vid:h0744wgkf6j 链接:http://v.qq.com/x/cover/wd7wvlekmeknnr6.html?vid=h0744wgkf6j
集数:28 标题:28_第28集_兵来将挡 vid:c07359bk5yj 链接:http://v.qq.com/x/cover/wd7wvlekmeknnr6.html?vid=c07359bk5yj
集数:27 标题:27_第27集_拉拢 vid:n0727t5tz53 链接:http://v.qq.com/x/cover/wd7wvlekmeknnr6.html?vid=n0727t5tz53
集数:26 标题:26_第26集_人之将死 vid:p0718un24oc 链接:http://v.qq.com/x/cover/wd7wvlekmeknnr6.html?vid=p0718un24oc
vid u8rljkriw7yeorg
首集链接 http://v.qq.com/cover/u/u8rljkriw7yeorg.html
详情页链接 http://v.qq.com/detail/u/u8rljkriw7yeorg.html
标题:X的天使
暂未更新
vid cvrmbhrlofhpt6f
首集链接 http://v.qq.com/cover/c/cvrmbhrlofhpt6f.html
详情页链接 http://v.qq.com/detail/c/cvrmbhrlofhpt6f.html
标题:天才玩偶
更新
http://s.video.qq.com/get_playsource?id=cvrmbhrlofhpt6f&plat=2&type=4&range=1&otype=json
集数:6 标题:6_天才玩偶_06 vid:e07516wbmu0 链接:http://v.qq.com/x/cover/cvrmbhrlofhpt6f.html?vid=e07516wbmu0
集数:5 标题:5_天才玩偶_05 vid:e0743g15yvp 链接:http://v.qq.com/x/cover/cvrmbhrlofhpt6f.html?vid=e0743g15yvp
集数:4 标题:4_天才玩偶_04 vid:o0735ty8mw5 链接:http://v.qq.com/x/cover/cvrmbhrlofhpt6f.html?vid=o0735ty8mw5
集数:3 标题:3_天才玩偶_03 vid:a07281ldpj8 链接:http://v.qq.com/x/cover/cvrmbhrlofhpt6f.html?vid=a07281ldpj8
集数:2 标题:2_天才玩偶_02 vid:o0719gm06fs 链接:http://v.qq.com/x/cover/cvrmbhrlofhpt6f.html?vid=o0719gm06fs
vid jrv6bdlps19hjso
首集链接 http://v.qq.com/cover/j/jrv6bdlps19hjso.html
详情页链接 http://v.qq.com/detail/j/jrv6bdlps19hjso.html
标题:世说新语
更新
http://s.video.qq.com/get_playsource?id=jrv6bdlps19hjso&plat=2&type=4&range=1&otype=json
集数:6 标题:6_第06集_月下笛 vid:w0751ihg81b 链接:http://v.qq.com/x/cover/jrv6bdlps19hjso.html?vid=w0751ihg81b
集数:5 标题:5_第05集_淝水之战 vid:m07439nilze 链接:http://v.qq.com/x/cover/jrv6bdlps19hjso.html?vid=m07439nilze
集数:4 标题:4_第04集_长门宴 vid:g07356tjugw 链接:http://v.qq.com/x/cover/jrv6bdlps19hjso.html?vid=g07356tjugw
集数:3 标题:3_第03集_竹林之游 vid:q0727xptawj 链接:http://v.qq.com/x/cover/jrv6bdlps19hjso.html?vid=q0727xptawj
集数:2 标题:2_第02集_思美人 vid:m0720rtjeap 链接:http://v.qq.com/x/cover/jrv6bdlps19hjso.html?vid=m0720rtjeap
vid dzukeudp58lsnnc
首集链接 http://v.qq.com/cover/d/dzukeudp58lsnnc.html
详情页链接 http://v.qq.com/detail/d/dzukeudp58lsnnc.html
标题:纳米学院
更新
http://s.video.qq.com/get_playsource?id=dzukeudp58lsnnc&plat=2&type=4&range=1&otype=json
集数:6 标题:6_纳米学院_06 vid:z0751om0edb 链接:http://v.qq.com/x/cover/dzukeudp58lsnnc.html?vid=z0751om0edb
集数:5 标题:5_纳米学院_05 vid:i07444lqv31 链接:http://v.qq.com/x/cover/dzukeudp58lsnnc.html?vid=i07444lqv31
集数:4 标题:4_纳米学院_04 vid:o073669ac2z 链接:http://v.qq.com/x/cover/dzukeudp58lsnnc.html?vid=o073669ac2z
集数:3 标题:3_纳米学院_03 vid:l07284t09ez 链接:http://v.qq.com/x/cover/dzukeudp58lsnnc.html?vid=l07284t09ez
集数:2 标题:2_纳米学院_02 vid:w07207vdph0 链接:http://v.qq.com/x/cover/dzukeudp58lsnnc.html?vid=w07207vdph0
vid gfjzjo0ea0f5oqn
首集链接 http://v.qq.com/cover/g/gfjzjo0ea0f5oqn.html
详情页链接 http://v.qq.com/detail/g/gfjzjo0ea0f5oqn.html
标题:魔法律事务所
暂未更新
一开始写了一个直接在网页解析结果的方法,结果有的剧太多,就需要另外加载才行。
于是直接用加载的接口请求完整的数据解析。
默认结果是打印更新的最新五集