302_poc_1.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import re
  2. import time
  3. from urllib import parse
  4. import requests
  5. def poc_1():
  6. net_url = 'https://t.livepocket.jp/purchase?type=new'
  7. result = requests.Session()
  8. header = {
  9. 'Host': 't.livepocket.jp',
  10. 'User-Agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
  11. "Chrome/69.0.3947.100 Safari/537.36",
  12. 'Content-Type': 'application/x-www-form-urlencoded',
  13. 'Referer': 'https://t.livepocket.jp/e/pp20240515',
  14. }
  15. my_session = 'IN7u3uuP5WcizQkmRzF%2F3OsLuNNQePnxNBvnlPgqT6FPz2BgyKT2KCJaMvdj8ZSa6wNp2xZIL6VoA7Mj0R2zECMZkOKJOLbsNwUdXwvcsROxjfCzibxEaj4nG%2Bq29dCEUdiWI2TgUsKSFGRZaOP0p37ktl%2B1wSMqMAk918Nkt7APIxpQtZ%2BoLwId4PMOkN3oOIwT3CvsuDbgPQHIuokZXcnNe8uOAUuZBLW4nKOdYimLcSw6oTMt85UXkwm4OyTdxYR3%2B8crA0OfQCyfHXqY%2Bj0t9R0mmNSusRXRDuDBmOCFR58vHVuuwZ0AXNHYoYB0sdm28VL9xgHHrzkvm2M9cpLEIVWUWBWGaZgtO3xp2d8L70%2BfAKwyv6JPGcGmGf9wUQzBltssBpMmYqSfkws1%2Bp8BOhmXOqfljSYbWcxxVVSw%2B2dtoxBXsTf793mD9sVYRsrr8YPGz4JPVGWGU0outg%3D%3D'
  16. cookies = {
  17. 'ci_session': f'{my_session}',
  18. 'list_count': '{"success":true,"result":{"myticket_count":{"count":"0"},"today_event":{"total_count":0,"data_list":[]},"unread_count":5},"submit":true}',
  19. 'sns_status': '{"success":true,"result":{"facebook":0,"twitter":0,"mixi":0,"line":0,"yahoo":0,"plusid":1,"google":0},"submit":true}',
  20. '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}',
  21. }
  22. form_data = {
  23. 'redirect_url': 'https://t.livepocket.jp/purchase/',
  24. 'event_id': '309887',
  25. 'event_cname': 'pp20240515',
  26. 'ticket_type': 'lottery',
  27. 'facebook_ticket_count': '0',
  28. 'twitter_ticket_count': '0',
  29. 'plusid_linkage_invalidation_flg': '0',
  30. 'ticket_id_1510471': '1'
  31. }
  32. response = result.post(net_url, headers=header, cookies=cookies, data=form_data, allow_redirects=False)
  33. print('response.headers: ', response.headers)
  34. # location_url = response.headers['Location']
  35. # region_string = location_url.split('?')[1]
  36. # params = region_string.split('&')
  37. # data = {
  38. # 'id': params[0].split('=')[1],
  39. # 'reserved_session_id': params[1].split('=')[1],
  40. # 'otoken': params[2].split('=')[1]
  41. # }
  42. #
  43. # return data
  44. def get_ticket_info():
  45. url = 'https://t.livepocket.jp/e/lxyyc'
  46. response = requests.get(url)
  47. if response.status_code == 200:
  48. html_string = response.text
  49. match = re.search(r'id="js_order_limited_(\d+)"', html_string)
  50. if match:
  51. number_value = match.group(1)
  52. print(number_value)
  53. else:
  54. print("未找到匹配的数值")
  55. def get_event_id():
  56. url = 'https://t.livepocket.jp/e/lxyyc'
  57. response = requests.get(url)
  58. if response.status_code == 200:
  59. html_string = response.content.decode('utf8')
  60. start_index = html_string.find('https://t.livepocket.jp/purchase/verify?event_id=')
  61. if start_index != -1:
  62. end_index = html_string.find("'", start_index)
  63. if end_index != -1:
  64. event_id = html_string[start_index + len('https://t.livepocket.jp/purchase/verify?event_id='):end_index]
  65. print(f'event_id: {event_id}')
  66. else:
  67. print('End index not found.')
  68. else:
  69. print('Substring not found.')
  70. else:
  71. print('Failed to fetch the page. Status code:', response.status_code)
  72. def get_my_session_id(account, passwd):
  73. """
  74. 模拟登录
  75. """
  76. # 定义请求地址
  77. login_url = "https://t.livepocket.jp/api/sessions/create?mytimestamp=" + str(int(time.time()))
  78. # 定义请求header
  79. headers = {'Content-Type': 'application/x-www-form-urlencoded;',
  80. 'Referer': 'https://t.livepocket.jp/login?acroot=header-new_p_u_nl',
  81. 'Sec-Ch-Ua': 'Chromium',
  82. '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'
  83. }
  84. # 通过字典方式定义请求body
  85. form_data = {"login": account,
  86. "password": passwd,
  87. "auto_login": "on",
  88. "login_password": f"{account}&{passwd}"
  89. }
  90. data = parse.urlencode(form_data)
  91. session = requests.session()
  92. content = session.post(url=login_url, headers=headers, data=data, proxies=None).text
  93. cookie = session.cookies
  94. response_cookie = cookie.get_dict()
  95. # login_resp = json.loads(content)
  96. # token = login_resp['result']['token']
  97. # print('response cookie: ', response_cookie)
  98. print('response_cookie: ', response_cookie)
  99. # 跳转到抢券
  100. login_session = response_cookie['ci_session']
  101. print(login_session)
  102. def get_event_name():
  103. url = 'https://t.livepocket.jp/e/lxyyc'
  104. sub_str = url.replace("https://t.livepocket.jp/", "")
  105. strs = sub_str.split('/')
  106. cname = strs[len(strs) - 1]
  107. print(cname)
  108. if __name__ == '__main__':
  109. # get_my_session_id('n0l1a@huatcn.com', 'panyue666')
  110. get_event_name()