Get Lottery Historical Draws Data for any State (CS Program)
Posted: 17 Mar 2019, 15:43
This CS program can be accessed here --> Historical Data Parser CS Program
See post #2 for version 2 which outputs without hyphens (-) so that data can be fed into Frequency Counter Program.
The CS program will allow you to paste the source code of results (year) page (from lotteryusa.com) as input and it'll parse the source code and print out draw data in text friendly format. One draw per line, numbers separated by hyphens, if there's a bonus (mega or whatever it's called) it'll printed between brackets (ie. "2-5-32-42-52-(6)").
You can then possibly use this text data to use in other CS programs or for your own analyzing. How you use it is up to you.
--------- INSTRUCTIONS ------------------------------------
Sample data output result from Florida Pick-3:
Sample data output result for Powerball:
See post #2 for version 2 which outputs without hyphens (-) so that data can be fed into Frequency Counter Program.
The CS program will allow you to paste the source code of results (year) page (from lotteryusa.com) as input and it'll parse the source code and print out draw data in text friendly format. One draw per line, numbers separated by hyphens, if there's a bonus (mega or whatever it's called) it'll printed between brackets (ie. "2-5-32-42-52-(6)").
You can then possibly use this text data to use in other CS programs or for your own analyzing. How you use it is up to you.
--------- INSTRUCTIONS ------------------------------------
- Go to www.lotteryusa.com
- Click on home
- Click on a State
- Click on "Year" under "Past Results" of a Lottery Type
- Right-click then select "View Source" (or Control+U on Firefox)
- Ctrl+A to select All, Ctrl+C to Copy all source code
- Run this program (top left "Run" button).
- Ctrl+V to paste source code into box when prompted
- That's it it'll parse the data and print out on right window (output window) results from oldest to latest draws, one draw on each line
Code: Select all
#This program will parse draw data results page (for year)
#of the source code of one of the yearly results page on
#www.lotteryusa.com
# --------- INSTRUCTIONS ------------------------------------
# Go to www.lotteryusa.com
# Click on home
# Click on a State
# Click on "Year" under "Past Results" of a Lottery Type
# Right-click then select "View Source" (or Control+U on Firefox)
# Ctrl+A to select All, Ctrl+C to Copy all source code
# Run this program (top left "Run" button).
# Ctrl+V to paste source code into box when prompted
# That's it it'll parse the data and print out on right window
# (output window) results from oldest to latest
# draws, one draw on each line
# -----------------------------------------------------------
#Developer notes:
#For pick 3s, source looks like this
#<ul class="draw-result list-unstyled list-inline">
# <li>2</li>
# <li>2</li>
# <li>9</li>
# </ul>
#For no bonus games, source looks like this
#<ul class="draw-result list-unstyled list-inline">
# <li>10</li>
# <li>11</li>
# <li>18</li>
# <li>30</li>
# <li>36</li>
# </ul>
#For games with bonus looks like this
#<ul class="draw-result list-unstyled list-inline">
# <li>3</li>
# <li>29</li>
# <li>56</li>
# <li>62</li>
# <li>64</li>
# <li class="bonus mega-ball">4
# <span>MB</span></li>
#or it could look like this for powerball but class starts with "bonus"
#<ul class="draw-result list-unstyled list-inline">
# <li>30</li>
# <li>34</li>
# <li>39</li>
# <li>53</li>
# <li>67</li>
# <li class="bonus powerball">11
# <span>PB</span></li>
# <li class="extra">Power Play: 2</li>
# </ul>
def pos_minimum(pos1,pos2,str1,str2):
pos = -1
s = ""
if pos1 >= 0:
pos = pos1
s = str1
if pos2 >= 0 and (pos2 < pos1 or pos1 < 0):
pos = pos2
s = str2
return pos,s
source = input("Please paste lotteryusa.com's Past results page sourcecode:")
ul_start = '<ul class="draw-result list-unstyled list-inline">'
ul_end = '</ul>'
li = '<li>'
li_end = '<'
li_bonus = '<li class="bonus'
li_bonus_2 = '>'
start = 0
start_i = source.find(ul_start,start)
draws = []
while (start_i >= 0):
end_i = source.find(ul_end,start_i + len(ul_start))
text = source[start_i + len(ul_start):end_i]
#print (text)
#here we have text which contains the ul element inner code
startpos = 0
li_start_i = text.find(li,startpos)
li_start_i2 = text.find(li_bonus,startpos)
start_pos,st = pos_minimum(li_start_i,li_start_i2,li,li_bonus)
draw = []
while (start_pos >= 0): #we have an li or a libonus
#look for bonus end
bonus = False
startpos = start_pos + len(st)
if st == li_bonus:
bonus = True
next_pos = text.find(li_bonus_2,startpos)
startpos = next_pos + len(li_bonus_2)
end_pos = text.find(li_end,startpos)
inner_text = text[startpos:end_pos]
#print (inner_text.strip())
if bonus:
draw.append('('+inner_text.strip()+')')
else:
draw.append(inner_text.strip())
#elements.append(int(inner_text.strip()))
li_start_i = text.find(li,startpos)
li_start_i2 = text.find(li_bonus,startpos)
start_pos,st = pos_minimum(li_start_i,li_start_i2,li,li_bonus)
draws.append(draw)
start = start_i + len(ul_start)
start_i = source.find(ul_start,start)
draws = draws[::-1]
for draw in draws:
print ("-".join(draw))
Code: Select all
2-6-0
9-4-2
2-6-9
6-3-8
1-8-9
2-1-7
6-5-3
4-7-2
4-6-3
9-7-6
9-9-4
4-0-9
4-6-2
2-5-3
6-2-3
1-5-8
0-3-2
1-1-2
0-0-7
6-9-6
5-0-4
5-8-2
3-1-9
7-8-1
1-2-6
9-7-9
7-2-8
8-5-2
2-1-4
9-9-9
6-7-9
8-3-1
3-1-8
5-3-5
7-1-4
5-6-4
8-6-0
9-7-4
8-4-2
8-8-4
2-2-5
7-3-5
4-8-5
8-4-1
7-8-5
1-3-7
2-5-1
0-0-8
0-2-9
5-0-7
9-1-6
2-1-8
4-5-4
7-6-5
6-9-6
2-4-5
0-2-8
4-7-0
8-8-1
6-7-9
5-5-1
7-7-5
6-9-4
3-2-2
7-9-0
1-0-2
5-9-6
1-7-4
6-0-6
5-2-3
4-2-1
5-5-2
9-1-5
0-8-1
3-7-8
4-4-9
5-4-9
7-8-9
6-7-3
2-7-7
1-4-8
2-0-7
6-6-8
2-9-9
7-3-5
1-4-3
8-1-3
9-7-0
2-2-2
9-8-8
5-5-2
9-5-9
7-0-1
9-0-3
9-1-8
1-9-0
7-0-9
3-0-7
5-5-7
0-4-0
0-0-2
8-1-7
5-7-0
1-7-9
2-3-8
9-8-5
5-9-3
2-9-5
1-0-6
1-1-7
9-0-7
5-9-0
5-7-3
5-2-2
9-3-2
9-0-9
1-3-6
1-6-4
1-1-5
8-0-6
8-3-0
3-7-1
0-7-6
7-9-0
9-9-2
6-3-7
5-5-3
7-9-2
0-0-3
1-2-0
2-4-1
5-3-7
7-1-1
8-0-6
4-5-1
7-8-1
7-7-4
4-2-8
8-4-4
3-1-8
6-9-6
1-8-5
2-1-7
3-6-1
4-4-3
1-0-1
9-1-8
6-9-5
1-2-1
8-2-9
1-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5-3-4
6-6-7
3-7-8
7-6-8
7-9-8
9-1-9
1-2-4
4-6-2
8-7-7
6-6-0
9-5-1
9-4-3
2-9-1
8-5-3
2-5-0
3-0-1
1-0-4
3-6-2
9-0-6
2-7-3
7-8-7
2-0-3
4-7-9
2-2-1
7-4-6
9-2-9
1-9-0
3-8-2
7-8-8
3-4-1
6-1-4
0-3-5
5-6-9
9-6-4
5-0-3
9-4-5
3-0-1
0-5-3
0-3-9
5-1-4
4-4-0
4-5-4
5-0-8
2-2-9
Code: Select all
22-57-59-60-66-(7)
3-4-18-29-61-(25)
10-33-45-53-56-(24)
6-8-26-52-53-(21)
8-24-52-55-61-(21)
8-24-42-54-64-(24)
2-17-20-38-39-(20)
16-18-27-55-67-(18)
17-19-26-61-62-(15)
9-10-12-17-23-(9)
40-50-54-62-69-(19)
17-18-39-56-64-(12)
20-22-28-45-50-(8)
5-14-31-40-50-(6)
14-29-36-57-61-(17)
11-16-38-50-69-(19)
22-42-45-55-56-(14)
17-19-21-22-51-(19)
3-6-9-17-56-(25)
20-54-56-61-64-(7)
1-21-31-45-49-(21)
17-23-26-46-68-(20)
23-25-37-44-64-(7)
23-28-41-53-56-(14)
6-10-15-25-36-(14)
13-20-38-45-55-(1)
9-45-57-58-65-(9)
4-14-23-27-56-(13)
16-29-43-45-56-(25)
7-28-37-62-63-(15)
3-9-20-42-61-(24)
4-7-15-41-44-(10)
1-10-43-45-64-(22)
19-21-27-46-47-(7)
22-41-42-49-67-(11)
1-10-27-28-36-(12)
9-23-56-58-68-(1)
2-18-41-44-64-(26)
22-27-46-56-65-(13)
5-22-32-38-58-(26)
3-11-38-44-58-(2)
10-21-30-43-63-(17)
5-43-56-62-68-(24)
12-15-28-47-48-(16)
24-34-52-61-67-(16)
1-7-45-47-69-(13)
20-25-54-57-63-(8)
25-41-53-57-67-(12)
11-54-55-61-66-(9)
6-15-50-59-60-(13)
3-13-20-32-33-(21)
6-28-48-63-64-(24)
2-18-19-24-34-(3)
4-39-48-50-51-(11)
24-61-63-64-69-(18)
1-2-7-30-50-(8)
9-17-34-59-64-(22)
41-53-59-63-66-(3)
1-22-27-53-67-(15)
8-23-27-42-60-(7)
11-14-32-43-65-(15)
3-57-64-68-69-(15)
16-54-57-62-69-(23)
3-21-45-53-56-(22)
8-12-13-19-27-(4)
7-25-39-40-47-(20)
15-21-24-32-65-(11)
26-28-34-42-50-(25)
5-29-34-53-57-(24)
7-42-49-62-69-(23)
6-8-20-52-68-(5)
7-14-23-38-55-(18)
11-33-51-56-58-(18)
4-19-59-68-69-(21)
10-11-47-55-58-(26)
9-11-36-37-38-(11)
14-32-34-46-61-(10)
4-9-21-29-64-(26)
8-38-43-52-55-(17)
15-29-31-37-43-(16)
21-28-30-40-59-(26)
5-25-38-52-67-(24)
12-42-51-53-62-(25)
8-12-42-46-56-(12)
3-7-15-27-69-(19)
6-19-37-49-59-(22)
7-36-48-57-58-(24)
14-29-31-56-61-(1)
5-8-41-65-66-(20)
23-25-47-48-50-(24)
8-12-20-21-32-(10)
2-12-16-29-54-(6)
10-17-18-43-65-(13)
5-13-28-38-63-(21)
1-2-3-7-39-(25)
2-8-14-24-69-(26)
29-30-41-48-64-(1)
27-49-50-51-52-(2)
4-6-14-20-32-(13)
21-31-42-49-59-(23)
1-19-25-27-68-(21)
6-10-21-35-46-(23)
5-6-45-55-59-(14)
18-36-45-47-69-(14)
30-34-39-53-67-(11)