Skip to content

Instantly share code, notes, and snippets.

@kunpengku
Created July 14, 2014 05:38
Show Gist options
  • Select an option

  • Save kunpengku/9629c38700e9529f48db to your computer and use it in GitHub Desktop.

Select an option

Save kunpengku/9629c38700e9529f48db to your computer and use it in GitHub Desktop.
tongji 彩票
#!/usr/local/bin/python
from urllib import urlopen
import re
import string
from datetime import *
import datetime
print 'Hello World'
p = re.compile('<td class="start" data-win-number=\'(.*?)\' data-period="(.*?)">(.*?)</td>')
themax=1
timelist = []
for i in range (11189):
print i
url = 'http://caipiao.163.com/award/jxssc/'
aday = (datetime.datetime.now() - datetime.timedelta(days = i)).strftime("%Y%m%d")
tmp = url + aday + '.html'
timelist.append(tmp)
for line in timelist:
print line
#webpage = urlopen('http://caipiao.163.com/award/jxssc/20140415.html')
webpage = urlopen(line)
doc = webpage.read()
webpage.close()
i = 1
resultlist = [None] * 85
for result, date, num in p.findall(doc):
#print '%s ,%s, %s' %(result,date,num)
num = string.atoi(num)
resultlist[num-1] = result
#print resultlist
#dan dan
dandan = 1
ss = 1
sd = 1
sdwin = 1
ds = 1
dswin = 1
wholedaymax = 1
sswholedaymax = 1
dswholedaymax = 1
sdwholedaymax = 1
for kai in resultlist:
if kai == None:
break
ge = kai[-1]
shi = kai[-3]
ge = string.atoi(ge)%2
shi = string.atoi(shi)%2
win = ge + shi
#print 'ret:' + kai
#dandan win
if win != 2:
dandan = dandan+1
else:
#print 'dandan win after buy %s times' % dandan
if dandan > wholedaymax:
wholedaymax = dandan
dandan = 1
#shuangshuang win
if win != 0:
ss = ss +1
else:
#print 'shuangshuang win after buy %s times' % ss
if ss > sswholedaymax:
sswholedaymax = ss
ss = 1
#danshuang
if shi == 1 and ge == 0:
dswin = 0
if dswin != 0:
ds = ds + 1
else:
#print 'danshuang win after buy %s times' % ds
if ds > dswholedaymax:
dswholedaymax = ds
ds = 1
dswin = 1
#shuangdan
if shi == 0 and ge == 1:
sdwin = 0
if sdwin != 0:
sd = sd + 1
else:
#print 'shuangdan win after buy %s times' % sd
if sd > sdwholedaymax:
sdwholedaymax = sd
sd = 1
sdwin = 1
print ' '
print 'ddwholedaymax=' + str(wholedaymax)
print 'sswholedaymax=' + str(sswholedaymax)
print 'dswholedaymax=' + str(dswholedaymax)
print 'sdwholedaymax=' + str(sdwholedaymax)
if themax < wholedaymax:
themax = wholedaymax
elif themax < sswholedaymax:
themax = sswholedaymax
elif themax < dswholedaymax:
themax = dswholedaymax
elif themax < sdwholedaymax:
themax = sdwholedaymax
print 'the max = ', themax
import time
print time.ctime()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment