From c5c0a25a30eed184592bd195bb3c0a73b1ca90e4 Mon Sep 17 00:00:00 2001 From: wbt5 Date: Fri, 31 Jul 2020 19:40:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=AC=E4=B8=9C=E7=9B=B4?= =?UTF-8?q?=E6=92=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 jd.py diff --git a/jd.py b/jd.py new file mode 100644 index 0000000..b9ed7ed --- /dev/null +++ b/jd.py @@ -0,0 +1,31 @@ +# 京东直播:https://h5.m.jd.com/dev/3pbY8ZuCx4ML99uttZKLHC2QcAMn/live.html?id=1807004&position=0 +import requests +import json + + +def jd(rid): + url = 'https://api.m.jd.com/client.action' + params = { + 'functionId': 'liveDetail', + 'body': json.dumps({'id': rid, 'videoType': 1}, separators=(',', ':')), + 'client': 'wh5' + } + with requests.Session() as s: + res = s.get(url, params=params).json() + data = res.get('data', 0) + if data: + status = data['status'] + if status == 1: + real_url = data['h5Pull'] + return real_url + else: + print('未开播') + real_url = '回放:' + data.get('playBack').get('videoUrl', 0) + return real_url + else: + raise Exception('直播间不存在') + + +if __name__ == '__main__': + r = input('输入京东直播间id:\n') + print(jd(r))