Created
February 3, 2016 01:45
-
-
Save chadmiller/610c16f1881fade10c14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import re | |
import urllib.request as ur | |
history = dict() | |
request = ur.urlopen("http://www.flalottery.com/exptkt/l6.htm") | |
page_bytes = request.read() | |
page_characters = page_bytes.decode(request.headers.get_content_charset() or "UTF-8") | |
lines = page_characters.split("\n") | |
current_day = None | |
for line in lines: | |
if "Page" in line: | |
continue # ignore a page number note | |
# match a date, then prepare a new container for numbers | |
match = re.search(">(\d+/\d+/\d+)<", line) | |
if match: | |
current_day = match.group(1) | |
history[current_day] = set() | |
match = re.search(">(\d+)<", line) | |
if match: | |
history[current_day].add(int(match.group(1))) | |
print(history) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment