#encoding:utf-8
import urllib2
from bs4 import BeautifulSoup
website = "http://caipiao.163.com/order/jczq-hunhe/#from=leftnav"
page = urllib2.urlopen(website)
soup = BeautifulSoup(page)
'''
获取场次以及分数合集比如
比分对应代码表:
11对应:1:1
70对应:胜其他
77对应:平其他
07对应:负其他
因此场次和比分结合为,017-10,017-20,017-21
'''
#场次信息 screening
i = 1
screening = []
for item in soup.findAll("span",{"class":"co1"}):
screening.append(item.i.string+'\n')
i+=1
sc = open('sc.txt','w')
sc.writelines(screening)
sc.close()
#比分标题 bifen
bifen=["1:0","2:0","2:1","3:0","3:1","3:2","4:0","4:1","4:2","5:0","5:1","5:2","胜其他","0:0","1:1","2:2","3:3","平其他","0:1","0:2","1:2","0:3","1:3","2:3","0:4","1:4","2:4","0:5","1:5","2:5","负其他"]
#场次+比分:ccbf
ccbf = []
for item_jtip in screening:
for item_bifen in bifen:
ccbf.append(item_jtip+item_bifen)
#之后遍历ccbf
for item in ccbf:
print item
#得到结果集如(场次为3位数字,第一个为主场比分,中间为冒号,最后一个为客场比分):
0281:1
0282:2
0283:3