""" 购买券 1、https://t.livepocket.jp/api/tickets/purchase?mytimestamp=1714488081955 2、https://t.livepocket.jp/api/promoter_notification_settings/update?mytimestamp=1714488083447 3、https://t.livepocket.jp/api/common/lists?dev=sp&mytimestamp=1714488092578 4、https://t.livepocket.jp/api/purchases/show?order_id=56707983&mytimestamp=1714488092592 """ import json import random import time import requests def step_buy(): step_timestamp = str(int(time.time())) event_id = 312360 reserved_session_id = random.randint(10000, 60000) headers = { 'Accept-Encoding': 'gzip, deflate, br, zstd', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Cache-Control': 'no-cache', 'Content-Type': 'application/x-www-form-urlencoded', 'Dnt': '1', 'Pragma': 'no-cache', 'Priority': 'u=0, i', 'Referer': f'https://t.livepocket.jp/purchase/confirm?id={event_id}&reserved_session_id={reserved_session_id}&otoken=zIxMWI1OTU5NzFhMzBmMTc3NGIxNmMxMWJkNz', 'Sec-Ch-Ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"macOS"', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'Sec-Fetch-User': '?1', 'Upgrade-Insecure-Requests': '1', 'authority': 't.livepocket.jp', 'method': 'POST', 'path': f'/api/tickets/purchase?mytimestamp={step_timestamp}', 'scheme': 'https', 'X-Requested-With': 'XMLHttpRequest', } cookies = {'ci_session': 'reVDw%2B7KCPX3SsuHQOr%2B0aP9nKNl1sf47wgSj8Dx%2FUk5RRpLMh1obUZWaMaTtOVF3zbqwmdXbIk%2F4GH21BtEf2YiHIW8EYro8orIAsbAISFmtjHbDXVIFhqQBM00YbIzbwRtuwTsBcTXw6nAa2Gg%2FmXrmuLS5zMUNvKRlcoLcyH%2Blkd0RV42XEHodR1vou46hsAwJsXNnG50QKqz94388TQHvDHSXF89iH4dtwyrKn7roJsGI4unz%2F106l1Nujk29Zfb%2BGeSBdWqZGmc5CjhQMDgUjBdBq%2B3MAiCMj5WfG7g1FcTXM4c2WmzZXIc2PdDxWZC%2FQk2XrQBE1pw%2B2%2B1AnX1flHweFpxloPcaI65ZqKE1uhg2Lqmjor3Z2fBAGJD7tgnzos2xiBr3bAVXcyl6Nri9pNlCrO3vAF14gDae9xGWKgTdRdrTfRpsmIUTt%2BdJGJ41baLunrGs%2F96X1At4w%3D%3D'} step1_url = 'https://t.livepocket.jp/api/tickets/purchase?mytimestamp=' + str(int(time.time())) form1_data = { 'utoken': 'utoken', 'onetime_token_name': 'buy_ticket', 'onetime_token_value': 'onetime_token_value', 'url': f'https://t.livepocket.jp/purchase/confirm?id={event_id}&reserved_session_id={reserved_session_id}', 'reserve_session_id': f'{reserved_session_id}', 'payment_method': '0', 'event_id': f'{event_id}', 'payment_type': 'credit' } step1_session = requests.session() step1_content = step1_session.post(url=step1_url, headers=headers, data=form1_data, cookies=cookies).text step1_json = json.loads(step1_content) print(f"step1_content:{step1_content}, error: {step1_json['errmsg']}") if __name__ == "__main__": step_buy()