1
0
mirror of https://github.com/wbt5/real-url.git synced 2025-07-27 11:00:32 +08:00

🎨 Improve 搜狐千帆直播

-优化代码
This commit is contained in:
wbt5 2021-11-21 14:55:09 +08:00
parent ccc5598774
commit df10de8686
No known key found for this signature in database
GPG Key ID: 92D5C42E815A2BD6

13
qf.py
View File

@ -8,14 +8,19 @@ import re
class QF: class QF:
def __init__(self, rid): def __init__(self, rid):
"""
搜狐千帆直播可以直接在网页源码里找到播放地址
Args:
rid: 数字直播间号
"""
self.rid = rid self.rid = rid
self.s = requests.Session()
def get_real_url(self): def get_real_url(self):
try: try:
response = requests.post(url='https://qf.56.com/' + self.rid).text res = self.s.post(url=f'https://qf.56.com/{self.rid}').text
real_url = re.findall(r"flvUrl:'(.*)\?wsSecret", response) real_url = re.search(r"flvUrl:'(.*)\?wsSecret", res).group(1)
real_url = real_url[0] except Exception:
except:
raise Exception('直播间不存在或未开播') raise Exception('直播间不存在或未开播')
return real_url return real_url