心血來潮,打算把雙色球歷史開獎(jiǎng)數(shù)據(jù)喂給大模型,讓大模型替我預(yù)測(cè)一下每期雙色球的開獎(jiǎng)結(jié)果。 所以第一步,就是搞定訓(xùn)練的數(shù)據(jù)源。 百度一下,輸入雙色球開獎(jiǎng)結(jié)果,看到了中彩網(wǎng),直接F12打開調(diào)試模式 get請(qǐng)求,不用登錄,這就很方便了。 寫python代碼 import requestsimport json# 動(dòng)態(tài)參數(shù),需要根據(jù)實(shí)際情況填充dynamic_timestamp = '1720075528388' # 例如從當(dāng)前時(shí)間生成dynamic_tt = '0.6040359491107643' # 可能是一個(gè)隨機(jī)數(shù)或時(shí)間戳# 請(qǐng)求URLurl = f'https://jc.zhcw.com/port/client_json.php?callback=jQuery1122009121818915345226_{dynamic_timestamp}&transactionType=10001001&lotteryId=1&issueCount=0&startIssue=2003001&endIssue=2024075&startDate=&endDate=&type=1&pageNum=1&pageSize=5000&tt={dynamic_tt}&_=1720075528388'# 請(qǐng)求頭headers = { 'Accept': '*/*', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept-Language': 'zh,zh-CN;q=0.9', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Cookie': 'PHPSESSID=r8r42jpq7tcs3rk46mc1gjei03; Hm_lvt_692bd5f9c07d3ebd0063062fb0d7622f=1720075529; Hm_lpvt_692bd5f9c07d3ebd0063062fb0d7622f=1720075529; _ga_9FDP3NWFMS=GS1.1.1720075529.1.0.1720075529.0.0.0; Hm_lvt_12e4883fd1649d006e3ae22a39f97330=1720075530; Hm_lpvt_12e4883fd1649d006e3ae22a39f97330=1720075530; _ga=GA1.2.692943629.1720075530; _gid=GA1.2.1494209071.1720075530; _gat_UA-66069030-3=1', 'Host': 'jc.zhcw.com', 'Pragma': 'no-cache', 'Referer': 'https://www.zhcw.com/', 'Sec-Ch-Ua': ''Not/A)Brand';v='8', 'Chromium';v='126', 'Google Chrome';v='126'', 'Sec-Ch-Ua-Mobile': '?1', 'Sec-Ch-Ua-Platform': ''Android'', 'Sec-Fetch-Dest': 'script', 'Sec-Fetch-Mode': 'no-cors', 'Sec-Fetch-Site': 'same-site', 'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36'}# 發(fā)送GET請(qǐng)求response = requests.get(url, headers=headers)# 檢查響應(yīng)狀態(tài)碼if response.status_code == 200: print('請(qǐng)求成功') # 處理響應(yīng)數(shù)據(jù) # 移除包裹在JSON數(shù)據(jù)外的JavaScript代碼,只保留JSON數(shù)據(jù)部分 json_data = response.text.split('(')[1].split(')')[0] # 將JSON數(shù)據(jù)轉(zhuǎn)換為Python字典 data_dict = json.loads(json_data) # 訪問'data'鍵下的列表 data_list = data_dict['data'] # 打印'data'列表中的每一項(xiàng) for item in data_list: for info in item['winnerDetails']: if info['awardEtc'] == '1': print('期號(hào):' + item['issue'], '開獎(jiǎng)日期:' + item['openTime'], '紅球:' + item['frontWinningNum'], '藍(lán)球:' + item['backWinningNum'])else: print(f'請(qǐng)求失敗,狀態(tài)碼:{response.status_code}') 打印結(jié)果 數(shù)據(jù)這不就來了嘛,明天就訓(xùn)練模型,試試效果。 |
|