| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- import re
- import time
- from urllib import parse
- import requests
- def poc_1():
- net_url = 'https://t.livepocket.jp/purchase?type=new'
- result = requests.Session()
- header = {
- 'Host': 't.livepocket.jp',
- 'User-Agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
- "Chrome/69.0.3947.100 Safari/537.36",
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Referer': 'https://t.livepocket.jp/e/pp20240515',
- }
- my_session = 'IN7u3uuP5WcizQkmRzF%2F3OsLuNNQePnxNBvnlPgqT6FPz2BgyKT2KCJaMvdj8ZSa6wNp2xZIL6VoA7Mj0R2zECMZkOKJOLbsNwUdXwvcsROxjfCzibxEaj4nG%2Bq29dCEUdiWI2TgUsKSFGRZaOP0p37ktl%2B1wSMqMAk918Nkt7APIxpQtZ%2BoLwId4PMOkN3oOIwT3CvsuDbgPQHIuokZXcnNe8uOAUuZBLW4nKOdYimLcSw6oTMt85UXkwm4OyTdxYR3%2B8crA0OfQCyfHXqY%2Bj0t9R0mmNSusRXRDuDBmOCFR58vHVuuwZ0AXNHYoYB0sdm28VL9xgHHrzkvm2M9cpLEIVWUWBWGaZgtO3xp2d8L70%2BfAKwyv6JPGcGmGf9wUQzBltssBpMmYqSfkws1%2Bp8BOhmXOqfljSYbWcxxVVSw%2B2dtoxBXsTf793mD9sVYRsrr8YPGz4JPVGWGU0outg%3D%3D'
- cookies = {
- 'ci_session': f'{my_session}',
- 'list_count': '{"success":true,"result":{"myticket_count":{"count":"0"},"today_event":{"total_count":0,"data_list":[]},"unread_count":5},"submit":true}',
- 'sns_status': '{"success":true,"result":{"facebook":0,"twitter":0,"mixi":0,"line":0,"yahoo":0,"plusid":1,"google":0},"submit":true}',
- 'display_init': '{"success":true,"result":{"purchased_tickets":{"total_count":0,"data_list":{"ticket_info":[]}},"lottery_tickets":{"total_count":0,"data_list":{"ticket_info":[]}},"order_limited_event_tickets":{"data_list":{"ticket_info":[]},"total_count":0},"event_order_limit":true},"submit":true}',
- }
- form_data = {
- 'redirect_url': 'https://t.livepocket.jp/purchase/',
- 'event_id': '309887',
- 'event_cname': 'pp20240515',
- 'ticket_type': 'lottery',
- 'facebook_ticket_count': '0',
- 'twitter_ticket_count': '0',
- 'plusid_linkage_invalidation_flg': '0',
- 'ticket_id_1510471': '1'
- }
- response = result.post(net_url, headers=header, cookies=cookies, data=form_data, allow_redirects=False)
- print('response.headers: ', response.headers)
- # location_url = response.headers['Location']
- # region_string = location_url.split('?')[1]
- # params = region_string.split('&')
- # data = {
- # 'id': params[0].split('=')[1],
- # 'reserved_session_id': params[1].split('=')[1],
- # 'otoken': params[2].split('=')[1]
- # }
- #
- # return data
- def get_ticket_info():
- url = 'https://t.livepocket.jp/e/lxyyc'
- response = requests.get(url)
- if response.status_code == 200:
- html_string = response.text
- match = re.search(r'id="js_order_limited_(\d+)"', html_string)
- if match:
- number_value = match.group(1)
- print(number_value)
- else:
- print("未找到匹配的数值")
- def get_event_id():
- url = 'https://t.livepocket.jp/e/lxyyc'
- response = requests.get(url)
- if response.status_code == 200:
- html_string = response.content.decode('utf8')
- start_index = html_string.find('https://t.livepocket.jp/purchase/verify?event_id=')
- if start_index != -1:
- end_index = html_string.find("'", start_index)
- if end_index != -1:
- event_id = html_string[start_index + len('https://t.livepocket.jp/purchase/verify?event_id='):end_index]
- print(f'event_id: {event_id}')
- else:
- print('End index not found.')
- else:
- print('Substring not found.')
- else:
- print('Failed to fetch the page. Status code:', response.status_code)
- def get_my_session_id(account, passwd):
- """
- 模拟登录
- """
- # 定义请求地址
- login_url = "https://t.livepocket.jp/api/sessions/create?mytimestamp=" + str(int(time.time()))
- # 定义请求header
- headers = {'Content-Type': 'application/x-www-form-urlencoded;',
- 'Referer': 'https://t.livepocket.jp/login?acroot=header-new_p_u_nl',
- 'Sec-Ch-Ua': 'Chromium',
- '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'
- }
- # 通过字典方式定义请求body
- form_data = {"login": account,
- "password": passwd,
- "auto_login": "on",
- "login_password": f"{account}&{passwd}"
- }
- data = parse.urlencode(form_data)
- session = requests.session()
- content = session.post(url=login_url, headers=headers, data=data, proxies=None).text
- cookie = session.cookies
- response_cookie = cookie.get_dict()
- # login_resp = json.loads(content)
- # token = login_resp['result']['token']
- # print('response cookie: ', response_cookie)
- print('response_cookie: ', response_cookie)
- # 跳转到抢券
- login_session = response_cookie['ci_session']
- print(login_session)
- if __name__ == '__main__':
- get_my_session_id('n0l1a@huatcn.com', 'panyue666')
|