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