From df10de8686054578efafcb2d9bc3d57a8228a602 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sun, 21 Nov 2021 14:55:09 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20Improve=20=E6=90=9C=E7=8B=90=E5=8D=83?= =?UTF-8?q?=E5=B8=86=E7=9B=B4=E6=92=AD=20-=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qf.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/qf.py b/qf.py index 1111839..cd65625 100644 --- a/qf.py +++ b/qf.py @@ -8,14 +8,19 @@ import re class QF: def __init__(self, rid): + """ + 搜狐千帆直播可以直接在网页源码里找到播放地址 + Args: + rid: 数字直播间号 + """ self.rid = rid + self.s = requests.Session() def get_real_url(self): try: - response = requests.post(url='https://qf.56.com/' + self.rid).text - real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response) - real_url = real_url[0] - except: + res = self.s.post(url=f'https://qf.56.com/{self.rid}').text + real_url = re.search(r"flvUrl:'(.*)\?wsSecret", res).group(1) + except Exception: raise Exception('直播间不存在或未开播') return real_url