From 17a1f788cbb418ac76fe3df39ff6494f5e8c17e7 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Sat, 25 Jul 2020 16:51:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=99=8C=E9=99=8C=E7=9B=B4?= =?UTF-8?q?=E6=92=AD=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- immomo.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 immomo.py diff --git a/immomo.py b/immomo.py new file mode 100644 index 0000000..9898321 --- /dev/null +++ b/immomo.py @@ -0,0 +1,31 @@ +import requests + + +def immomo(rid): + url = 'https://web.immomo.com/webmomo/api/scene/profile/roominfos' + data = { + 'stid': rid, + 'src': 'url' + } + + with requests.Session() as s: + s.get('https://web.immomo.com') + res = s.post(url, data=data).json() + + ec = res.get('ec', 0) + if ec != 200: + raise Exception('请求参数错误') + else: + live = res['data']['live'] + if live: + real_url = res['data']['url'] + return real_url + else: + raise Exception('未开播') + + +if __name__ == '__main__': + r = input('输入陌陌直播房间号:\n') + print(immomo(r)) + +# https://web.immomo.com/live/337033339