xubo 1 год назад
Родитель
Сommit
18f18ddd77
8 измененных файлов с 418 добавлено и 74 удалено
  1. 1 1
      .idea/awesome-python.iml
  2. 1 1
      .idea/misc.xml
  3. 96 72
      livepocket/buy_poc.py
  4. 35 0
      livepocket/get_params.py
  5. 140 0
      livepocket/query_params.py
  6. 95 0
      livepocket/test_poc.py
  7. 13 0
      tools/utils.py
  8. 37 0
      x/spider_poc.py

+ 1 - 1
.idea/awesome-python.iml

@@ -2,7 +2,7 @@
 <module type="PYTHON_MODULE" version="4">
   <component name="NewModuleRootManager">
     <content url="file://$MODULE_DIR$" />
-    <orderEntry type="jdk" jdkName="awesome-python" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
   <component name="PyDocumentationSettings">

+ 1 - 1
.idea/misc.xml

@@ -3,5 +3,5 @@
   <component name="Black">
     <option name="sdkName" value="Python 3.12" />
   </component>
-  <component name="ProjectRootManager" version="2" project-jdk-name="awesome-python" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
 </project>

+ 96 - 72
livepocket/buy_poc.py

@@ -1,95 +1,119 @@
 import json
+import random
 import time
+from urllib import parse
 
 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 = {
-        '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',
-        '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',
-        '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__':
-    test_poc()
+    buy_poc("nvlu8@huatcn.com", "panyue666", 'https://t.livepocket.jp/e/glimas0504')

+ 35 - 0
livepocket/get_params.py

@@ -0,0 +1,35 @@
+import requests
+
+
+def query_params_o_token(net_url, my_session, origin_url):
+    net_url = "https://t.livepocket.jp/purchase/confirm?id=314095&reserved_session_id=809279"
+    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",
+        # 'Referer': f'{origin_url}',
+    }
+    cookies = {
+        'ci_session': f'{my_session}'
+    }
+    response = result.get(net_url, headers=header, cookies=cookies, allow_redirects=False)
+    print('response', response)
+    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
+
+
+if __name__ == '__main__':
+    my_session = {
+        'ci_session': 'w2uNUg2evDN3Y5p9FF6ov%2BeGbOd1bG2G6TcquqbP6s%2BS8sHGzdxFsQiX9MZfADOXtJoTezlRRTMnSHN6eKM4Jj2R9JfAqm4H5VDBp6uMnftQGB4tJLSqk6xAKRi3R9BeAwFh8KQF75VAY88apyvHXzSIr3Cbad5dS2kY4bvj3AiKORmlwm8XamH%2FRr5%2BGYVc20ci0TZ5%2FRft5%2FiU6Du3mBKVqh4wQmKezkwZd7VIWC5FaApglFF%2FNAeuBxgsCnrBEJABu734BJXqHECPiEWWhI5BYx1X2V%2BjIxUI%2Fv6%2FwLDsPPmdwq0tO3mAMHSyMfo402xjZN0iVX3ZwFby2%2Bp8VUSfJdz7DfgZO1FcC62H2n12yJUaatCcXeWn6RgykRzO04o%2BeasJVIwML215vCI6YmgvdRiwSCDlr7QB4%2F5Ae7ZByAE0qk9Ofx4yEHXfjNSlN5j1JN7iNN6NYMkc0raVsQ%3D%3D'
+    }
+
+    query_params_o_token(my_session)

+ 140 - 0
livepocket/query_params.py

@@ -0,0 +1,140 @@
+import json
+import time
+from urllib import parse
+
+import requests
+
+
+def query_event(account, passwd, target_url):
+    """
+    模拟登录
+    """
+    # 定义请求地址
+    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']
+    event_id = 0
+    php_session = response_cookie['PHPSESSID']
+
+    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)
+
+    return event_id, login_session, php_session
+
+
+def query_params_reserved_session_id(id, my_session, php_session_id, origin_url):
+    reserved_url = f"https://t.livepocket.jp/purchase/security?id={id}&type=new"
+    result = requests.Session()
+    header = {
+        'Host': 't.livepocket.jp',
+        'DNT': '1',
+        'Upgrade-Insecure-Requests': '1',
+        '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-Fetch-Site': 'same-origin',
+        'Sec-Fetch-Mode': 'navigate',
+        'Sec-Fetch-User': '?1',
+        'Referer': f'{origin_url}',
+        'Sec-Fetch-Dest': 'document',
+        '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"',
+        'Accept-Language': 'zh-CN,zh;q=0.9',
+        'Accept-Encoding': 'gzip, deflate, br, zstd',
+        'Cache-Control': 'max-age=0'
+    }
+
+    cookies = {
+        'ci_session': f'{my_session}',
+        'PHPSESSID': f'{php_session_id}',
+        'list_count': '{"success":true,"result":{"myticket_count":{"count":"1"},"today_event":{"total_count":1,"data_list":[{"id":"310461","name":"【5月5日(日・祝)】アイビー×ケンティー 着こなしと香りの完全攻略ガイド(先着受付)","artist":"アイビー, ケンティー","event_pic_url":"https://t.livepocket.jp/image/ogDi7QnoXzcjytaA6A08BX0Sezyx5XvndoMMJZiSH3LxVO6uyKHGY7KdKX6DbaAC","loc_name":"ジェイアール名古屋タカシマヤ 7階 ローズパティオ","date_info":{"startname":"開演日時","endname":"終演日時","starttime":"2024-05-05 10:15:00","endtime":"2024-05-05 18:30:00"},"order_status":""}]},"unread_count":10},"submit":true}'.encode('utf-8').decode('latin1'),
+        '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}'.encode('utf-8').decode('latin1'),
+        'sns_status': '{"success":true,"result":{"facebook":0,"twitter":0,"mixi":0,"line":0,"yahoo":0,"plusid":1,"google":0},"submit":true}'.encode('utf-8').decode('latin1')
+    }
+    response = result.get(reserved_url, headers=header, cookies=cookies, allow_redirects=False)
+    print('response.headers:', response.headers)
+    redirect_url = response.headers['Location']
+    print('redirect_url:', redirect_url)
+
+    return redirect_url
+
+
+def query_params_o_token(net_url, my_session, origin_url):
+    net_url = "https://t.livepocket.jp/purchase/confirm?id=314095&reserved_session_id=809279"
+    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",
+        # 'Referer': f'{origin_url}',
+    }
+    cookies = {
+        'ci_session': f'{my_session}'
+    }
+    response = result.get(net_url, headers=header, cookies=cookies, allow_redirects=False)
+    print('response', response)
+    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
+
+
+if __name__ == '__main__':
+    # url = 'https://t.livepocket.jp/e/55minholidays_1'
+    #
+    # event_id, x_session, php_session = query_event("n8vzi@huatcn.com", "panyue666", url)
+    # x_url = query_params_reserved_session_id(event_id, x_session, php_session, url)
+    # data = query_params_o_token(x_url, x_session, url)
+    # print(data)
+
+    my_session = {
+        'ci_session': 'w2uNUg2evDN3Y5p9FF6ov%2BeGbOd1bG2G6TcquqbP6s%2BS8sHGzdxFsQiX9MZfADOXtJoTezlRRTMnSHN6eKM4Jj2R9JfAqm4H5VDBp6uMnftQGB4tJLSqk6xAKRi3R9BeAwFh8KQF75VAY88apyvHXzSIr3Cbad5dS2kY4bvj3AiKORmlwm8XamH%2FRr5%2BGYVc20ci0TZ5%2FRft5%2FiU6Du3mBKVqh4wQmKezkwZd7VIWC5FaApglFF%2FNAeuBxgsCnrBEJABu734BJXqHECPiEWWhI5BYx1X2V%2BjIxUI%2Fv6%2FwLDsPPmdwq0tO3mAMHSyMfo402xjZN0iVX3ZwFby2%2Bp8VUSfJdz7DfgZO1FcC62H2n12yJUaatCcXeWn6RgykRzO04o%2BeasJVIwML215vCI6YmgvdRiwSCDlr7QB4%2F5Ae7ZByAE0qk9Ofx4yEHXfjNSlN5j1JN7iNN6NYMkc0raVsQ%3D%3D'
+    }
+
+    query_params_o_token(None, my_session, None)

+ 95 - 0
livepocket/test_poc.py

@@ -0,0 +1,95 @@
+import json
+import time
+
+import requests
+
+
+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',
+    }
+
+    # 定义要传递给GET请求的参数字典
+    params = {
+        'limit': 10,
+        'offset': 0,
+        'utoken': 'utoken',
+        'past': 'false',
+        'event_id': 307219
+    }
+
+    # 发送GET请求
+    response = requests.get(url, params=params, headers=headers)
+
+    data = json.loads(response.text)
+
+    print(data)
+
+
+def by_poc():
+    url = 'https://t.livepocket.jp/purchase/verify?event_id=307219'
+
+    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',
+    }
+
+    response = requests.get(url, allow_redirects=False, headers=headers)
+
+    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)
+
+
+if __name__ == '__main__':
+    test_poc()

+ 13 - 0
tools/utils.py

@@ -0,0 +1,13 @@
+from random import Random
+
+
+# 随机生成token
+def get_token():
+    length_r = 32
+    token = ''
+    chars = '01'
+    length = len(chars) - 1
+    random = Random()
+    for i in range(length_r):
+        token += chars[random.randint(0, length)]
+    return token

+ 37 - 0
x/spider_poc.py

@@ -0,0 +1,37 @@
+import os
+import sys
+import time
+
+import uiautomator2 as u2
+from cnocr import CnOcr
+
+
+def spider_poc(serial):
+    d = u2.connect(serial)
+    d.screen_on()
+    d.unlock()
+    d.debug = False
+
+    d.app_stop("com.facebook.katana")
+    d.app_start("com.facebook.katana", use_monkey=True)
+    time.sleep(3)
+
+    # 搜索
+    d.xpath('//*[@content-desc="搜索"]').click(timeout=3)
+    d.xpath('//*[@text="搜索"]').click(timeout=3)
+    d(focused=True).set_text('电子元器件')
+
+    d.press('enter')
+
+    root_dir = os.path.dirname(sys.argv[0])
+    screenshot_name = f'screenshots/{time.time()}.png'
+    screenshot_dir = os.path.join(root_dir, screenshot_name)
+    d.screenshot().save(screenshot_dir)
+
+    ocr = CnOcr()
+    res = ocr.ocr(screenshot_dir)
+    print(res)
+
+
+if __name__ == '__main__':
+    spider_poc('5D7HSG5XXCKVBI85')