超级大乐透基本投注是指从前区号码中任选五个号码,并从后区号码中任选两个号码的组合进行投注。其中,前区号码由01—35共三十五个号码组成,后区号码由01—12共十二个号码组成。
一等奖:投注号码与当期开奖号码全部相同(顺序不限,下同),即中奖;
二等奖:投注号码与当期开奖号码中的五个前区号码及任意一个后区号码相同,即中奖;
三等奖:投注号码与当期开奖号码中的五个前区号码相同,即中奖;
从大乐透网站获取中奖数据
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from lxml import etree
import time
from openpyxl import Workbook
driver = webdriver.Chrome()
wb = Workbook()
ws = wb.active
driver.implicitly_wait(10)
url = "https://www.lottery.gov.cn/kj/kjlb.html?dlt"
driver.get(url)
iframe = driver.find_element(By.ID, "iFrame1")
driver.switch_to.frame(iframe)
page = 1
p = 0
while page <= 85:
np = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH, "//li[contains(text(),'下一页')]")))
e = driver.find_element(By.ID, "historyData")
# time.sleep(3)
# np = driver.find_element(By.XPATH, "//li[contains(text(),'下一页')]")
html = e.get_attribute("outerHTML")
tree = etree.HTML(html)
n = int(tree.xpath('count(//tbody/tr)'))
for i in range(1,n+1):
if int(tree.xpath('count(//tbody/tr['+str(i)+']/td)')) != 20:
continue
row = []
for j in range(1,10):
row.append(tree.xpath('//tbody/tr['+str(i)+']/td['+str(j)+']//text()')[0])
ws.append(row)
print(row)
p += 1
print("===========")
np.click()
time.sleep(2)
page += 1
driver.switch_to.default_content()
wb.save("lottery.xlsx")
time.sleep(30)
# driver.quit()
统计中奖数据中各球出现的次数
from openpyxl import load_workbook
def returnSum(d):
sum = 0
for i in d:
sum += d[i]
return sum
wb = load_workbook("lottery.xlsx")
ws = wb.active
max_row = ws.max_row
countA = {
}
for i in range(1,36):
countA[i] = 0
countB = {
}
for i in range(1,13):
countB[i] = 0
for row in ws.values:
for i in range(2,7):
countA[int(row[i])] += 1
for j in range(7,9):
countB[int(row[j])] += 1
print(max_row*5, max_row*2)
n = returnSum(countA)
print(n)
m = returnSum(countB)
print(m)
print(sorted(countA.items(), key=lambda x:x[1]))
print(sorted(countB.items(), key=lambda x:x[1]))
截止2024年3月11日,中奖号码按出现次数排序由低到高为
[(16, 301), (24, 326), (15, 327), (4, 329), (12, 331), (21, 332), (9, 334), (8, 336), (13, 337), (10, 341), (14, 341), (17, 341), (28, 345), (18, 346), (26, 348), (6, 354), (20, 354), (27, 355), (23, 357), (2, 363), (3, 364), (25, 366), (5, 369), (11, 369), (19, 375), (7, 379), (1, 382), (31, 382), (34, 391), (22, 392), (32, 418), (30, 423), (35, 434), (33, 435), (29, 438)]
[(8, 390), (1, 394), (4, 412), (6, 413), (3, 417), (9, 425), (2, 427), (11, 427), (5, 430), (12, 443), (7, 453), (10, 455)]
文章评论