From f6f978277569acc731aaecee115edd13e55e6c06 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=88=91=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 --- woxiu.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 woxiu.py diff --git a/woxiu.py b/woxiu.py new file mode 100644 index 0000000..577ea7c --- /dev/null +++ b/woxiu.py @@ -0,0 +1,27 @@ +# 我秀直播:https://www.woxiu.com/ +import requests + + +def woxiu(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' + } + url = 'https://m.woxiu.com/index.php?action=M/Live&do=LiveInfo&room_id={}'.format(rid) + with requests.Session() as s: + res = s.get(url, headers=headers) + try: + res = res.json() + except: + raise Exception('直播间不存在') + status = res['online'] + if status: + live_stream = res['live_stream'] + return live_stream + else: + raise Exception('未开播') + + +if __name__ == '__main__': + r = input('输入我秀直播房间号:\n') + print(woxiu(r))