[No.003-1]爬虫网易赔率数据并导入到mysql数据库

#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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值