From b5090adea9a0eab22659e52d97ff33148ebf19e7 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:44:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B9=9D=E7=A7=80=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 9xiu.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 9xiu.py diff --git a/9xiu.py b/9xiu.py new file mode 100644 index 0000000..bbfb924 --- /dev/null +++ b/9xiu.py @@ -0,0 +1,26 @@ +# 九秀直播:https://www.9xiu.com/other/classify?tag=all&index=all +import requests + + +def j_xiu(rid): + with requests.Session() as s: + url = 'https://h5.9xiu.com/room/live/enterRoom?rid=' + str(rid) + headers = { + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) ' + 'AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1' + } + res = s.get(url, headers=headers).json() + if res['code'] == 200: + status = res['data']['status'] + if status == 0: + raise Exception('未开播') + elif status == 1: + live_url = res['data']['live_url'] + return live_url + else: + raise Exception('直播间可能不存在') + + +if __name__ == '__main__': + r = input('输入九秀直播房间号:\n') + print(j_xiu(r))