|
@@ -1,95 +1,119 @@
|
|
|
import json
|
|
import json
|
|
|
|
|
+import random
|
|
|
import time
|
|
import time
|
|
|
|
|
+from urllib import parse
|
|
|
|
|
|
|
|
import requests
|
|
import requests
|
|
|
|
|
|
|
|
|
|
+from tools.utils import get_token
|
|
|
|
|
|
|
|
-def test_poc():
|
|
|
|
|
- url = 'https://t.livepocket.jp/api/purchased_tickets/total_list'
|
|
|
|
|
|
|
|
|
|
- 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': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
|
|
|
- 'Accept-Language': 'zh-CN,zh;q=0.9',
|
|
|
|
|
- 'Cache-Control': 'no-cache',
|
|
|
|
|
- 'Cookie': 'ci_session=TB9aP0ffcS6uK2rhcUxhb1uF8ZUaWY7oqwDg3OpGk2zZmFYAihTkYadqnniR%2FoQ7g8KCK7RXdNJ109aeJcryfm4UyOeyu3nQCiDIcLkzRgtYsb%2B%2B431iz1DaG4lM0NG0wcM5EQ0BJrbyNPiaD7CJNlp1HuPr20WnV3ml89zcpbtBHfF4x%2BjasqtD06l8Kn%2BO%2Filjg4y%2BUaAXnyLd%2FmrnAhDgteJV%2F44Awl1ZHw0cE6PvDQq1Fsw%2Be6Ym4HzWIvRvFTSGdUqhKaYMZIclfZJUUHHhhqfbJ59cJualWNx38LRgAonOEtYOBGxWv97LBGTJ0EQU0KxLxJGsBHOZKTQuQ%2FAAwaqCwDAuRcx1cOhXBUwQhS8LTqqJQOPLYJj4r5QF8KbrnnQ1S0kNMlxGx13fpifnnAvtoZ5HfCk9sGcGpvs3jJxaCjYGAry8Ljhl65CHgQEXC5xcp1SOwNeTW%2BZhrA%3D%3D',
|
|
|
|
|
- 'Dnt': '1',
|
|
|
|
|
- 'Pragma': 'no-cache',
|
|
|
|
|
- 'Priority': 'u=0, i',
|
|
|
|
|
- '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': 'document',
|
|
|
|
|
- 'Sec-Fetch-Mode': 'navigate',
|
|
|
|
|
- 'Sec-Fetch-Site': 'none',
|
|
|
|
|
- 'Sec-Fetch-User': '?1',
|
|
|
|
|
- 'Upgrade-Insecure-Requests': '1',
|
|
|
|
|
- 'authority': 't.livepocket.jp',
|
|
|
|
|
- 'method': 'GET',
|
|
|
|
|
- 'path': '/api/purchased_tickets/total_list?limit=10&offset=0&past=false&event_id=307219&utoken=utoken',
|
|
|
|
|
- 'scheme': 'https',
|
|
|
|
|
- }
|
|
|
|
|
|
|
+def buy_poc(account, passwd, target_url='https://t.livepocket.jp/e/4gbm0'):
|
|
|
|
|
+ """
|
|
|
|
|
+ 模拟登录
|
|
|
|
|
+ """
|
|
|
|
|
+ # 定义请求地址
|
|
|
|
|
+ login_url = "https://t.livepocket.jp/api/sessions/create?mytimestamp=" + str(int(time.time()))
|
|
|
|
|
|
|
|
- # 定义要传递给GET请求的参数字典
|
|
|
|
|
- params = {
|
|
|
|
|
- 'limit': 10,
|
|
|
|
|
- 'offset': 0,
|
|
|
|
|
- 'utoken': 'utoken',
|
|
|
|
|
- 'past': 'false',
|
|
|
|
|
- 'event_id': 307219
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ # 定义请求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'
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- # 发送GET请求
|
|
|
|
|
- response = requests.get(url, params=params, headers=headers)
|
|
|
|
|
|
|
+ # 通过字典方式定义请求body
|
|
|
|
|
+ form_data = {"login": account,
|
|
|
|
|
+ "password": passwd,
|
|
|
|
|
+ "auto_login": "on",
|
|
|
|
|
+ "login_password": f"{account}&{passwd}"
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- data = json.loads(response.text)
|
|
|
|
|
|
|
+ data = parse.urlencode(form_data)
|
|
|
|
|
|
|
|
- print(data)
|
|
|
|
|
|
|
+ # 代理IP池
|
|
|
|
|
+ proxy_list = [
|
|
|
|
|
+ '185.199.228.220:7300',
|
|
|
|
|
+ ]
|
|
|
|
|
|
|
|
|
|
+ # 随机从ip池中选出一个ip
|
|
|
|
|
+ proxy = random.choice(proxy_list)
|
|
|
|
|
+ proxies = {
|
|
|
|
|
+ 'http': 'http://' + proxy,
|
|
|
|
|
+ 'https': 'https://' + proxy,
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-def by_poc():
|
|
|
|
|
- url = 'https://t.livepocket.jp/purchase/verify?event_id=307219'
|
|
|
|
|
|
|
+ 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)
|
|
|
|
|
+ print(f"token: {login_resp['result']['token']}, response_cookie:{response_cookie}")
|
|
|
|
|
+ # print(login_resp)
|
|
|
|
|
+ token = login_resp['result']['token']
|
|
|
|
|
+ reserved_session_id = random.randint(100000, 600000)
|
|
|
|
|
+ ci_session = json.dumps(session.cookies.get_dict())
|
|
|
|
|
|
|
|
|
|
+ # 跳转到抢券
|
|
|
|
|
+ event_id = 0
|
|
|
|
|
+ response = requests.get(target_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)
|
|
|
|
|
+
|
|
|
|
|
+ url = 'https://t.livepocket.jp/api/tickets/purchase?mytimestamp=' + str(int(time.time()))
|
|
|
|
|
+ # reserved_session_id = 125846
|
|
|
|
|
+
|
|
|
|
|
+ one_token = get_token()
|
|
|
headers = {
|
|
headers = {
|
|
|
- 'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
|
|
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
'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',
|
|
'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': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
|
|
|
|
|
+ 'sec-ch-ua-mobile': '?0',
|
|
|
|
|
+ 'DNT': '1',
|
|
|
|
|
+ 'sec-ch-ua': '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"',
|
|
|
|
|
+ 'Host': 't.livepocket.jp',
|
|
|
|
|
+ 'Accept': 'application/json, text/javascript, */*; q=0.01',
|
|
|
|
|
+ 'X-Requested-With': 'XMLHttpRequest',
|
|
|
|
|
+ 'sec-ch-ua-platform': '"macOS"',
|
|
|
|
|
+ 'Origin': 'https://t.livepocket.jp',
|
|
|
|
|
+ 'Sec-Fetch-Site': 'same-origin',
|
|
|
|
|
+ 'Sec-Fetch-Mode': 'cors',
|
|
|
|
|
+ 'Sec-Fetch-Dest': 'empty',
|
|
|
|
|
+ 'Referer': f'https://t.livepocket.jp/purchase/confirm?id={event_id}&reserved_session_id={reserved_session_id}&otoken={one_token}',
|
|
|
|
|
+ 'Accept-Encoding': 'gzip, deflate, br, zstd',
|
|
|
'Accept-Language': 'zh-CN,zh;q=0.9',
|
|
'Accept-Language': 'zh-CN,zh;q=0.9',
|
|
|
- 'Cache-Control': 'no-cache',
|
|
|
|
|
- 'Cookie': 'ci_session=TB9aP0ffcS6uK2rhcUxhb1uF8ZUaWY7oqwDg3OpGk2zZmFYAihTkYadqnniR%2FoQ7g8KCK7RXdNJ109aeJcryfm4UyOeyu3nQCiDIcLkzRgtYsb%2B%2B431iz1DaG4lM0NG0wcM5EQ0BJrbyNPiaD7CJNlp1HuPr20WnV3ml89zcpbtBHfF4x%2BjasqtD06l8Kn%2BO%2Filjg4y%2BUaAXnyLd%2FmrnAhDgteJV%2F44Awl1ZHw0cE6PvDQq1Fsw%2Be6Ym4HzWIvRvFTSGdUqhKaYMZIclfZJUUHHhhqfbJ59cJualWNx38LRgAonOEtYOBGxWv97LBGTJ0EQU0KxLxJGsBHOZKTQuQ%2FAAwaqCwDAuRcx1cOhXBUwQhS8LTqqJQOPLYJj4r5QF8KbrnnQ1S0kNMlxGx13fpifnnAvtoZ5HfCk9sGcGpvs3jJxaCjYGAry8Ljhl65CHgQEXC5xcp1SOwNeTW%2BZhrA%3D%3D',
|
|
|
|
|
- 'Dnt': '1',
|
|
|
|
|
- 'Pragma': 'no-cache',
|
|
|
|
|
- 'Priority': 'u=0, i',
|
|
|
|
|
- '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': 'document',
|
|
|
|
|
- 'Sec-Fetch-Mode': 'navigate',
|
|
|
|
|
- 'Sec-Fetch-Site': 'none',
|
|
|
|
|
- 'Sec-Fetch-User': '?1',
|
|
|
|
|
- 'Upgrade-Insecure-Requests': '1',
|
|
|
|
|
- 'authority': 't.livepocket.jp',
|
|
|
|
|
- 'method': 'GET',
|
|
|
|
|
- 'path': '/api/purchased_tickets/total_list?limit=10&offset=0&past=false&event_id=307219&utoken=utoken',
|
|
|
|
|
- 'scheme': 'https',
|
|
|
|
|
|
|
+ 'Cookie': f'ci_session={ci_session}'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- response = requests.get(url, allow_redirects=False, headers=headers)
|
|
|
|
|
|
|
+ form_data = {
|
|
|
|
|
+ 'utoken': f'{token}',
|
|
|
|
|
+ 'onetime_token_name': 'buy_ticket',
|
|
|
|
|
+ 'onetime_token_value': one_token,
|
|
|
|
|
+ '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}',
|
|
|
|
|
+ 'serial_codes': 'null',
|
|
|
|
|
+ 'fan_club': 'null',
|
|
|
|
|
+ 'payment_type': 'credit'
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if response.status_code == 302:
|
|
|
|
|
- redirect_url = response.headers['Location']
|
|
|
|
|
- print("Redirect URL:", redirect_url)
|
|
|
|
|
- # 使用新的重定向URL再次发起请求
|
|
|
|
|
- new_response = requests.get(redirect_url)
|
|
|
|
|
- if new_response.status_code == 200:
|
|
|
|
|
- content = new_response.text
|
|
|
|
|
- print(content)
|
|
|
|
|
- else:
|
|
|
|
|
- print('Failed to fetch the redirected page. Status code:', new_response.status_code)
|
|
|
|
|
- else:
|
|
|
|
|
- print('Initial request did not result in a redirect. Status code:', response.status_code)
|
|
|
|
|
|
|
+ cookies = {'ci_session': f'{ci_session}'}
|
|
|
|
|
+
|
|
|
|
|
+ response = requests.post(url, headers=headers, cookies=cookies, data=form_data)
|
|
|
|
|
+ print(json.loads(response.text))
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
|
- test_poc()
|
|
|
|
|
|
|
+ buy_poc("nvlu8@huatcn.com", "panyue666", 'https://t.livepocket.jp/e/glimas0504')
|