摘要:所以我不得不做的就是把每天的賠率數(shù)據(jù)導(dǎo)入到我自己的數(shù)據(jù)庫,根據(jù)一定的運(yùn)算法則,將可能性篩選出來,然后我再做進(jìn)一步的判斷。
首先,我擁有這個(gè)導(dǎo)入賠率的需求,并且,我需要的是所有的數(shù)據(jù)賠率,我需要把某些臟賠率(極有可能不會(huì)出現(xiàn)的賠率,誤導(dǎo)彩迷的賠率)刪除,并且我需要知道這些賠率的比分,刪除這些賠率,可以逆推正確比分以及賠率的區(qū)間。 所以我不得不做的就是把每天的賠率數(shù)據(jù)導(dǎo)入到我自己的數(shù)據(jù)庫,根據(jù)一定的運(yùn)算法則,將可能性篩選出來,然后我再做進(jìn)一步的判斷。
#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) for incident in soup("td"): print incident 得到類似于以下的結(jié)果集:負(fù)其他 120.000 14.001 5.202 3.553 3.504 4.705 7.506 13.007+ ……18.00
這里得到的結(jié)果,僅僅是賠率的結(jié)果,而且需要吧gametype的內(nèi)容篩選出來,得到緊缺的,總進(jìn)球 7球 18賠率的結(jié)果;
接下來提取td中的內(nèi)容,使用re正則來提?。?br> 直接在for循環(huán)中使用re,避免使用文件作為緩存
#查詢半全場的賠率 for item in soup.findAll("td",{"gametype":"bqc"}): print item.find("div").string
#查詢表中的標(biāo)簽,并將內(nèi)容篩選出來 #半全場賠率,依次為"勝勝","勝平","勝負(fù)","平勝","平平","平負(fù)","負(fù)勝","負(fù)平","負(fù)負(fù)" for item in soup.findAll("td",{"gametype":"bqc"}): print item.find("div").string #再查詢比分賠率 #先是勝賠,1:0~勝其他,之后是平賠,0:0~3:3,平其他,并將其導(dǎo)入比分賠率bfpl temp = ["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","負(fù)其他"] i = 1 bfpl = [] for item in soup.findAll("td",{"gametype":"bf"}): bfpl.append(item.find("div").string) #--------------------- #構(gòu)建比分賠率字典 i = 1 temp = ["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","負(fù)其他"] len #再查詢總進(jìn)球賠率 for item in soup.findAll("td",{"gametype":"zjq"}): print item.find("div").string #---------------------------------------- #查詢所有的主隊(duì)、客隊(duì)名字?jǐn)?shù)據(jù)以及場次數(shù)據(jù) #主隊(duì)hostTeam i = 1 hostTeam = [] for item in soup.findAll("em",{"class":"hostTeam"}): hostTeam.append(item.b.string) i+=1 for item in hostTeam: print hostTeam[item] #客隊(duì)guestTeam i = 1 guestTeam = [] for item in soup.findAll("em",{"class":"guestTeam"}): guestTeam.append(item.b.string) i+=1 for item in guestTeam: print guestTeam[item] #------------------ #場次以及主隊(duì)客隊(duì)數(shù)據(jù) #------------------ i = 1 for item in hostTeam: print "---------" print screening[i],hostTeam[i],guestTeam[i] i+=1 #----------------------- #場次信息 jtip i = 1 screening = [] for item in soup.findAll("span",{"class":"co1"}): screening.append(item.i.string) i+=1 #遍歷場次數(shù)據(jù) i=1 for item in screening: print screening[i] i+=1 #------------------ #做出場次+比分的list-->scbf[] for item in screening: i=0 while i
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/37346.html
摘要:獲取場次以及分?jǐn)?shù)合集比如比分對應(yīng)代碼表對應(yīng)對應(yīng)勝其他對應(yīng)平其他對應(yīng)負(fù)其他因此場次和比分結(jié)合為,場次信息比分標(biāo)題勝其他平其他負(fù)其他場次比分之后遍歷得到結(jié)果集如場次為位數(shù)字,第一個(gè)為主場比分,中間為冒號,最后一個(gè)為客場比分平其他 #encoding:utf-8 import urllib2 from bs4 import BeautifulSoup website = http://ca...
摘要:創(chuàng)建比賽結(jié)果數(shù)據(jù)庫導(dǎo)入結(jié)果到導(dǎo)入到數(shù)據(jù)庫中更新勝負(fù)數(shù)據(jù)插入更新勝場勝其他更新負(fù)場負(fù)其他更新平局平其他查看更新結(jié)果 創(chuàng)建比賽結(jié)果數(shù)據(jù)庫 CREATE TABLE `results` ( `id` char(14) NOT NULL, `scr` char(3) NULL , `lea` char(100) NULL , `gmd` date NULL , `hos` char...
摘要:創(chuàng)建數(shù)據(jù)庫以及表,并導(dǎo)入數(shù)據(jù)創(chuàng)建數(shù)據(jù)庫創(chuàng)建表勝分?jǐn)?shù)比分平負(fù)導(dǎo)入數(shù)據(jù)導(dǎo)入到數(shù)據(jù)庫中 創(chuàng)建數(shù)據(jù)庫以及表,并導(dǎo)入數(shù)據(jù) --創(chuàng)建數(shù)據(jù)庫 CREATE DATABASE `data` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; --創(chuàng)建表 --win w 勝 0 分?jǐn)?shù) 1 比分 --draw d 平 --lose l 負(fù) C...
摘要:收集比賽結(jié)果場次先獲得包含和其他信息的隊(duì)列賽事類型比賽日期刪除無效的前個(gè)數(shù)據(jù)主隊(duì),客隊(duì)勝平負(fù)賠率刪除首尾兩個(gè)無效數(shù)據(jù)比分結(jié)果以及比分結(jié)果賠率形成場次日期唯一裝配結(jié)果集更新數(shù)據(jù)庫內(nèi)容更新勝平負(fù)勝其他平其他負(fù)其他更新總進(jìn)球勝其 收集比賽結(jié)果 #encoding:utf-8 import sys import urllib2 import re from bs4 import Beauti...
閱讀 2458·2021-11-19 09:40
閱讀 3586·2021-11-17 17:08
閱讀 3784·2021-09-10 10:50
閱讀 2214·2019-08-27 10:56
閱讀 1942·2019-08-27 10:55
閱讀 2638·2019-08-26 12:14
閱讀 994·2019-08-26 11:58
閱讀 1494·2019-08-26 10:43