コード例 #1
0
ファイル: period_sc.py プロジェクト: marpaUAH/server
def object_date(fdate):
	return datetime.date(int(fdate[0:4]), int(fdate[5:7]), int(fdate[8:10]))

### Funcion para obtener un objeto datetime a partir de 'yyyy-mm-dd'
def int_todate(rdate):
	fdate=str(rdate)
	return datetime.date(int(fdate[0:4]), int(fdate[4:6]), int(fdate[6:8]))

# Comienzo del script
# First check the last element on DBs
# Beebotte
foundoc_b = bclient.read('Lottery', 'Date', limit=1)
foundoc_b = int_todate(foundoc_b[0]['data'])

#MongoDB
foundoc_m = lnumbers.find().sort('_id', -1)
foundoc_m = object_date(foundoc_m[0]['date'])

# Determine the number of dates that are necessary to get from the HTML code based on the difference between the last date stored and the current date
one_day = datetime.timedelta(days=1)
today = datetime.date.today()
yesterday = today - one_day

b_times = int((yesterday-foundoc_b).days)
m_times = int((yesterday-foundoc_m).days)

# Get the last numbers	from website's HTML code
f = urllib2.urlopen('http://www.resultados11.es')
results = re.findall('<div id="bolas">.+?</div>|<div class="center fs16">.+?</div>|>[0-9]{3}<', f.read())
l_num = []