Skip to content

Instantly share code, notes, and snippets.

@batok
Created December 15, 2009 01:18
Show Gist options
  • Save batok/256621 to your computer and use it in GitHub Desktop.
Save batok/256621 to your computer and use it in GitHub Desktop.
# Vamos haciendo este programa compatible con python 3.
from urllib.request import urlopen
import zipfile
import sys
numeros = dict()
MELATE_ZIP_URL = "http://www.pronosticos.gob.mx/pago/Files/melate.zip"
REVANCHA_ZIP_URL = "http://www.pronosticos.gob.mx/pago/Files/revancha.zip"
MELATE_FILE = "MELATE.CSV"
REVANCHA_FILE = "REVANCHA.CSV"
sorteo = 2289
sorteo_actual = 0
try:
sorteo = int(sys.argv[1])
except:
pass
for localfile, url in ((MELATE_FILE, MELATE_ZIP_URL),(REVANCHA_FILE, REVANCHA_ZIP_URL)):
with open("PROVISIONAL.zip", "wb") as f:
f.write(urlopen(url).read())
file = zipfile.ZipFile("PROVISIONAL.zip","r")
with open(localfile,"wb") as f:
f.write(file.read(localfile))
for localfile in ( MELATE_FILE, REVANCHA_FILE ):
with open(localfile) as f:
for line in f:
campos = line.split(",")
try:
xsorteo = int(campos[1])
sorteo_actual = max( xsorteo, sorteo_actual )
if xsorteo >= sorteo:
for x in range(2,9):
numeros[int(campos[x])] = True
except:
pass
print("El sorteo mas reciente es {0}".format(sorteo_actual))
print( "A partir del sorteo {0}".format(sorteo))
print( [x for x in range(1,57) if x not in numeros])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment