提交 bd6f0197 编写于 作者: S shi.zeyuan

1.增加索引 2.基本面爬取数据问题 3.基本面分析算法问题

上级 aceb9f32
......@@ -39,7 +39,7 @@
<tr>
<td><span style="color: {{color .AlFlag}}">{{.AlFlag}}</span></td>
<td style="color: red">
<strong>{{.HitCount}}</strong>
<strong>{{/*{{.HitCount}}*/}}</strong>
</td>
<td>{{.MatchDateStr}}</td>
<td>{{.LeagueName}}</td>
......
......@@ -15,7 +15,7 @@ type BFBattle struct {
/**
* 比赛时间
*/
BattleMatchDate time.Time `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId)"`
BattleMatchDate time.Time `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId) index"`
/**
* 联赛Id
*/
......@@ -23,7 +23,7 @@ type BFBattle struct {
/**
* 主队id,目前为主队名称
*/
BattleMainTeamId string `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId)"`
BattleMainTeamId string `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId) index"`
/**
* 主队进球数
*/
......@@ -32,7 +32,7 @@ type BFBattle struct {
/**
* 客队id,目前为客队名称
*/
BattleGuestTeamId string `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId)"`
BattleGuestTeamId string `xorm:"unique(BattleMatchDate_MainTeamId_GuestTeamId) index"`
/**
* 客队进球数
*/
......
......@@ -10,12 +10,15 @@ import (
*/
type BFFutureEvent struct {
//比赛id
MatchId string `xorm:"comment('比赛ID') index"`
MatchId string `xorm:"comment('比赛ID') unique(MatchId_TeamId_EventMatchDate) index"`
/**
* 队伍名称
*/
TeamId string `xorm:" comment('队伍名称') unique(MatchId_TeamId_EventMatchDate) index"`
/**
* 比赛时间
*/
EventMatchDate time.Time `xorm:"unique(EventMatchDate_MainTeamId_GuestTeamId)"`
EventMatchDate time.Time `xorm:" comment('比赛时间') unique(MatchId_TeamId_EventMatchDate) index"`
/**
* 联赛Id
*/
......@@ -23,16 +26,15 @@ type BFFutureEvent struct {
/**
* 主队id,目前为主队名称
*/
EventMainTeamId string `xorm:"unique(EventMatchDate_MainTeamId_GuestTeamId)"`
EventMainTeamId string `xorm:" comment('主队id,目前为主队名称') index "`
/**
* 客队id,目前为客队名称
*/
EventGuestTeamId string `xorm:"unique(EventMatchDate_MainTeamId_GuestTeamId)"`
EventGuestTeamId string `xorm:" comment('客队id,目前为客队名称') index "`
/**
间隔天数
*/
IntervalDay int `xorm:" comment('间隔天数') index"`
pojo.BasePojo `xorm:"extends"`
}
......@@ -7,14 +7,14 @@ import "tesou.io/platform/foot-parent/foot-api/common/base/pojo"
*/
type BFScore struct {
//比赛id
MatchId string `xorm:"comment('比赛ID') unique(MatchId_TeamId_Type)"`
MatchId string `xorm:"comment('比赛ID') unique(MatchId_TeamId_Type) index"`
/**
* 主队id,目前为主队名称
* 球队ID
*/
TeamId string `xorm:"comment('球队ID') unique(MatchId_TeamId_Type)"`
TeamId string `xorm:"comment('球队ID') unique(MatchId_TeamId_Type) index"`
// 总 , 主 ,客 近
Type string `xorm:"comment('类型:总,主,客,近') unique(MatchId_TeamId_Type)"`
Type string `xorm:"comment('类型:总,主,客,近') unique(MatchId_TeamId_Type) index"`
//比赛场次
MatchCount int `xorm:"comment('比赛场次') index"`
......
......@@ -13,7 +13,7 @@ type MatchLast struct {
/**
* 比赛时间
*/
MatchDate time.Time `xorm:"unique(MatchDate_MainTeamId_GuestTeamId)"`
MatchDate time.Time `xorm:"unique(MatchDate_MainTeamId_GuestTeamId) index"`
/**
数据时间
......@@ -26,7 +26,7 @@ type MatchLast struct {
/**
* 主队id,目前为主队名称
*/
MainTeamId string `xorm:"unique(MatchDate_MainTeamId_GuestTeamId)"`
MainTeamId string `xorm:"unique(MatchDate_MainTeamId_GuestTeamId) index"`
/**
* 主队进球数
*/
......@@ -34,7 +34,7 @@ type MatchLast struct {
/**
* 客队id,目前为客队名称
*/
GuestTeamId string `xorm:"unique(MatchDate_MainTeamId_GuestTeamId)"`
GuestTeamId string `xorm:"unique(MatchDate_MainTeamId_GuestTeamId) index"`
/**
* 客队进球数
*/
......
......@@ -22,11 +22,11 @@ type AsiaHis struct {
ELetBall float64 `xorm:" comment('e让球') index"`
//博彩公司id
CompId string `xorm:"unique(CompId_MatchId_OddDate)"`
CompId string `xorm:"unique(CompId_MatchId_OddDate) index"`
//比赛id
MatchId string `xorm:"unique(CompId_MatchId_OddDate)"`
MatchId string `xorm:"unique(CompId_MatchId_OddDate) index"`
//数据时间
OddDate string `xorm:"unique(CompId_MatchId_OddDate)"`
OddDate string `xorm:"unique(CompId_MatchId_OddDate) index"`
pojo.BasePojo `xorm:"extends"`
}
......@@ -8,9 +8,9 @@ import (
*/
type AsiaLast struct {
//博彩公司id
CompId string `xorm:"unique(CompId_MatchId)"`
CompId string `xorm:"unique(CompId_MatchId) index"`
//比赛id
MatchId string `xorm:"unique(CompId_MatchId)"`
MatchId string `xorm:"unique(CompId_MatchId) index"`
/**
初主队盘口赔率
......
......@@ -21,11 +21,11 @@ type EuroHis struct {
Ep0 float64
//博彩公司id
CompId string `xorm:"unique(CompId_MatchId_OddDate)"`
CompId string `xorm:"unique(CompId_MatchId_OddDate) index"`
//比赛id
MatchId string `xorm:"unique(CompId_MatchId_OddDate)"`
MatchId string `xorm:"unique(CompId_MatchId_OddDate) index"`
//数据时间
OddDate string `xorm:"unique(CompId_MatchId_OddDate)"`
OddDate string `xorm:"unique(CompId_MatchId_OddDate) index"`
//赔付率
Payout float64
......
......@@ -8,9 +8,9 @@ import (
*/
type EuroLast struct {
//博彩公司id
CompId string `xorm:"unique(CompId_MatchId)"`
CompId string `xorm:"unique(CompId_MatchId) index"`
//比赛id
MatchId string `xorm:"unique(CompId_MatchId)"`
MatchId string `xorm:"unique(CompId_MatchId) index"`
/**
初盘胜平负赔率
......
package service
import (
"fmt"
"math"
"strconv"
"tesou.io/platform/foot-parent/foot-api/common/base"
......@@ -87,13 +88,12 @@ func (this *C1Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
return -1, nil
}
a18betData = aList[0]
if matchId == "1738911"{
}
if math.Abs(a18betData.ELetBall) > this.MaxLetBall {
return -2, nil
}
if matchId == "1742923" {
fmt.Println("-")
}
//得出结果
var preResult int
letBall := 0.00
......@@ -106,31 +106,63 @@ func (this *C1Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
//排名越小越好
rankDiff := 4.0
var temp_val float64
temp_val = float64(bfs_arr[0].Ranking - bfs_arr[4].Ranking)
var mainZongBfs *pojo.BFScore
var mainZhuBfs *pojo.BFScore
var guestZongBfs *pojo.BFScore
var guestKeBfs *pojo.BFScore
for _, e := range bfs_arr {
if e.TeamId == v.MainTeamId {
if e.Type == "总" {
mainZongBfs = e
}
if e.Type == "主" {
mainZhuBfs = e
}
} else {
if e.Type == "总" {
guestZongBfs = e
}
if e.Type == "客" {
guestKeBfs = e
}
}
}
if mainZongBfs == nil || guestZongBfs == nil || mainZhuBfs == nil || guestKeBfs == nil {
return -1, nil
}
temp_val = float64(mainZongBfs.Ranking - guestZongBfs.Ranking)
if temp_val >= rankDiff {
letBall += -0.25 * (temp_val / rankDiff)
letBall += -0.25 - (temp_val/rankDiff)*0.1
}
temp_val = float64(bfs_arr[4].Ranking - bfs_arr[0].Ranking)
temp_val = float64(guestZongBfs.Ranking - mainZongBfs.Ranking)
if temp_val >= rankDiff {
letBall += 0.25 * (temp_val / rankDiff)
letBall += 0.25 + (temp_val/rankDiff)*0.1
}
temp_val = float64(bfs_arr[1].Ranking - bfs_arr[6].Ranking)
temp_val = float64(mainZhuBfs.Ranking - guestKeBfs.Ranking)
if temp_val >= rankDiff {
letBall += -0.25 * (temp_val / rankDiff)
letBall += -0.25 - (temp_val/rankDiff)*0.1
}
temp_val = float64(bfs_arr[6].Ranking - bfs_arr[1].Ranking)
temp_val = float64(guestKeBfs.Ranking - mainZhuBfs.Ranking)
if temp_val >= rankDiff {
letBall += 0.25 * (temp_val / rankDiff)
letBall += 0.25 + (temp_val/rankDiff)*0.1
}
//------
bfb_arr := this.BFBattleService.FindByMatchId(matchId)
mainWin := 0
guestWin := 0
for _, e := range bfb_arr {
if e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
if e.BattleMainTeamId == v.MainTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
mainWin++
}
if e.BattleMainTeamId == v.MainTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
mainWin++
}
if e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
if e.BattleMainTeamId == v.GuestTeamId && e.BattleMainTeamGoals > e.BattleGuestTeamGoals {
guestWin++
}
if e.BattleMainTeamId == v.GuestTeamId && e.BattleGuestTeamGoals > e.BattleMainTeamGoals {
guestWin++
}
}
......@@ -158,40 +190,47 @@ func (this *C1Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
} else {
mainLetball = false
}
sLetBall := math.Abs(a18betData.SLetBall)
eLetBall := math.Abs(a18betData.ELetBall)
tLetBall := math.Abs(letBall)
if (sLetBall >= tLetBall && eLetBall >= tLetBall) || (sLetBall < tLetBall && eLetBall >= tLetBall ){
if math.Abs(eLetBall-tLetBall) < 0.26 {
if mainLetball {
preResult = 3
} else {
preResult = 0
}
}else{
if mainLetball {
preResult = 0
} else {
preResult = 3
}
}
}else if (sLetBall < tLetBall && eLetBall < tLetBall) || (sLetBall >= tLetBall && eLetBall < tLetBall ) {
if math.Abs(tLetBall-eLetBall) < 0.26 {
if mainLetball {
preResult = 3
if a18betData.ELetBall > 0 && letBall < 0 {
preResult = 3
} else if a18betData.ELetBall < 0 && letBall > 0 {
preResult = 0
} else {
sLetBall := math.Abs(a18betData.SLetBall)
eLetBall := math.Abs(a18betData.ELetBall)
tLetBall := math.Abs(letBall)
if (sLetBall >= tLetBall && eLetBall >= tLetBall) || (sLetBall < tLetBall && eLetBall >= tLetBall) {
if math.Abs(eLetBall-tLetBall) < 0.26 {
if mainLetball {
preResult = 3
} else {
preResult = 0
}
} else {
preResult = 0
if mainLetball {
preResult = 0
} else {
preResult = 3
}
}
}else{
if mainLetball {
preResult = 0
} else if (sLetBall < tLetBall && eLetBall < tLetBall) || (sLetBall >= tLetBall && eLetBall < tLetBall) {
if math.Abs(tLetBall-eLetBall) < 0.26 {
if mainLetball {
preResult = 3
} else {
preResult = 0
}
} else {
preResult = 3
if mainLetball {
preResult = 0
} else {
preResult = 3
}
}
} else {
base.Log.Error("C1分析模型出现错误!!!")
}
}else {
base.Log.Error("C1分析模型出现错误!!!")
}
base.Log.Info("计算得出让球为:", letBall, ",初盘让球:", a18betData.SLetBall, ",即时盘让球:", a18betData.ELetBall)
var data *entity5.AnalyResult
......
......@@ -5,6 +5,7 @@ import (
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
"time"
)
type BFBattleService struct {
......@@ -21,3 +22,14 @@ func (this *BFBattleService) FindByMatchId(matchId string) []*pojo.BFBattle {
}
return dataList
}
func (this *BFBattleService) Exist(battleMatchDate time.Time, battleMainTeamId string, battleGuestTeamId string) bool {
sql_build := strings.Builder{}
battleMatchDateStr := battleMatchDate.Format("2006-01-02 15:04:05")
sql_build.WriteString(" BattleMatchDate = '" + battleMatchDateStr + "' AND BattleMainTeamId = '" + battleMainTeamId + "' AND BattleGuestTeamId = '" + battleGuestTeamId + "'")
result, err := mysql.GetEngine().Where(sql_build.String()).Exist(new(pojo.BFBattle))
if err != nil {
base.Log.Error("Exist:", err)
}
return result
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import (
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
"time"
)
type BFFutureEventService struct {
......@@ -14,7 +15,7 @@ type BFFutureEventService struct {
func (this *BFFutureEventService) FindByMatchId(matchId string) []*pojo.BFFutureEvent {
dataList := make([]*pojo.BFFutureEvent, 0)
sql_build := strings.Builder{}
sql_build.WriteString(" MatchId = '" + matchId+"'")
sql_build.WriteString(" MatchId = '" + matchId + "'")
err := mysql.GetEngine().Where(sql_build.String()).Find(&dataList)
if err != nil {
base.Log.Error("FindByMatchId:", err)
......@@ -22,13 +23,24 @@ func (this *BFFutureEventService) FindByMatchId(matchId string) []*pojo.BFFuture
return dataList
}
func (this *BFFutureEventService) FindNextBattle(matchId string,mainId string) *pojo.BFFutureEvent {
func (this *BFFutureEventService) FindNextBattle(matchId string, mainId string) *pojo.BFFutureEvent {
data := new(pojo.BFFutureEvent)
sql_build := strings.Builder{}
sql_build.WriteString(" MatchId = '" + matchId +"'")
_,err := mysql.GetEngine().Where(sql_build.String()).OrderBy(" EventMatchDate ASC").Get(data)
sql_build.WriteString(" MatchId = '" + matchId + "' and TeamId = '" + mainId + "'")
_, err := mysql.GetEngine().Where(sql_build.String()).OrderBy(" EventMatchDate ASC").Get(data)
if err != nil {
base.Log.Error("FindNextBattle:", err)
}
return data
}
func (this *BFFutureEventService) Exist(matchId string, teamId string, eventMatchDate time.Time) bool {
sql_build := strings.Builder{}
eventMatchDateStr := eventMatchDate.Format("2006-01-02 15:04:05")
sql_build.WriteString(" MatchId = '" + matchId + "' AND TeamId = '" + teamId + "' AND EventMatchDate = '" + eventMatchDateStr + "'")
result, err := mysql.GetEngine().Where(sql_build.String()).Exist(new(pojo.BFFutureEvent))
if err != nil {
base.Log.Error("Exist:", err)
}
return result
}
......@@ -14,10 +14,20 @@ type BFScoreService struct {
func (this *BFScoreService) FindByMatchId(matchId string) []*pojo.BFScore {
dataList := make([]*pojo.BFScore, 0)
sql_build := strings.Builder{}
sql_build.WriteString(" MatchId = '" + matchId+"'")
sql_build.WriteString(" MatchId = '" + matchId + "'")
err := mysql.GetEngine().Where(sql_build.String()).Find(&dataList)
if err != nil {
base.Log.Error("FindByMatchId:", err)
}
return dataList
}
func (this *BFScoreService) Exist(matchId string, teamId string, types string) bool {
sql_build := strings.Builder{}
sql_build.WriteString(" MatchId = '" + matchId + "' AND TeamId = '" + teamId + "' AND Type = '" + types + "'")
result,err := mysql.GetEngine().Where(sql_build.String()).Exist(new(pojo.BFScore))
if err != nil {
base.Log.Error("Exist:", err)
}
return result
}
......@@ -161,6 +161,56 @@ func (this *SuggestTodayService) ModifyToday(wcClient *core.Client) {
今日赛事分析
*/
func (this *SuggestTodayService) ModifyTodayDetail(wcClient *core.Client) {
param := new(vo.SuggestVO)
now := time.Now()
h12, _ := time.ParseDuration("-24h")
beginDate := now.Add(h12)
param.BeginDateStr = beginDate.Format("2006-01-02 15:04:05")
h12, _ = time.ParseDuration("24h")
endDate := now.Add(h12)
param.EndDateStr = endDate.Format("2006-01-02 15:04:05")
//今日推荐
param.AlFlag = getAlFlag()
tempList := this.SuggestService.Query(param)
//更新推送
first := material.Article{}
first.Title = fmt.Sprintf("赛事解析")
first.Digest = fmt.Sprintf("赛事的模型算法解析")
first.ThumbMediaId = today_detail_thumbMediaId
first.ContentSourceURL = contentSourceURL
first.Author = utils.GetVal("wechat", "author")
temp := vo.TodayVO{}
temp.SpiderDateStr = constants.SpiderDateStr
temp.BeginDateStr = param.BeginDateStr
temp.EndDateStr = param.EndDateStr
temp.DataDateStr = now.Format("2006-01-02 15:04:05")
temp.DataList = make([]vo.SuggestVO, len(tempList))
for i, e := range tempList {
e.MatchDateStr = e.MatchDate.Format("02号15:04")
temp.DataList[i] = *e
}
var buf bytes.Buffer
tpl, err := template.New("today_detail.html").Funcs(getFuncMap()).ParseFiles("assets/wechat/html/today_detail.html")
if err != nil {
base.Log.Error(err)
}
if err := tpl.Execute(&buf, &temp); err != nil {
base.Log.Fatal(err)
}
first.Content = buf.String()
err = material.UpdateNews(wcClient, today_mediaId, 1, &first)
if err != nil {
base.Log.Error(err)
}
}
/**
今日赛事分析
*/
func (this *SuggestTodayService) ModifyTodayDetailNew(wcClient *core.Client) {
param := new(vo.SuggestDetailVO)
now := time.Now()
h12, _ := time.ParseDuration("-24h")
......
......@@ -67,22 +67,70 @@ func (this *BaseFaceProcesser) Process(p *page.Page) {
matchId := this.Win007idMatchidMap[win007Id]
//积分榜
scoreSaveList := make([]interface{}, 0)
scoreModifyList := make([]interface{}, 0)
scoreList := this.score_process(matchId, p)
for _, e := range scoreList {
exist := this.BFScoreService.Exist(e.MatchId, e.TeamId, e.Type)
if exist {
scoreModifyList = append(scoreModifyList, e)
} else {
scoreSaveList = append(scoreSaveList, e)
}
}
if len(scoreSaveList) > 0 {
this.BFScoreService.SaveList(scoreSaveList)
}
if len(scoreModifyList) > 0 {
this.BFScoreService.ModifyList(scoreModifyList)
}
//对战历史
battleSaveList := make([]interface{}, 0)
battleModifyList := make([]interface{}, 0)
battleList := this.battle_process(matchId, p)
for _, e := range battleList {
exist := this.BFBattleService.Exist(e.BattleMatchDate, e.BattleMainTeamId, e.BattleGuestTeamId)
if exist {
battleModifyList = append(battleModifyList, e)
} else {
battleSaveList = append(battleSaveList, e)
}
}
if len(battleSaveList) > 0 {
this.BFBattleService.SaveList(battleSaveList)
}
if len(battleModifyList) > 0 {
this.BFBattleService.ModifyList(battleModifyList)
}
//未来对战
futureEventSaveList := make([]interface{}, 0)
futureEventModifyList := make([]interface{}, 0)
futureEventList := this.future_event_process(matchId, p)
//保存数据
this.BFScoreService.SaveList(scoreList)
this.BFBattleService.SaveList(battleList)
this.BFFutureEventService.SaveList(futureEventList)
for _, e := range futureEventList {
exist := this.BFFutureEventService.Exist(e.MatchId,e.TeamId,e.EventMatchDate)
if exist {
futureEventModifyList = append(futureEventModifyList, e)
} else {
futureEventSaveList = append(futureEventSaveList, e)
}
}
if len(futureEventSaveList) > 0 {
this.BFFutureEventService.SaveList(futureEventSaveList)
}
if len(futureEventModifyList) > 0 {
this.BFFutureEventService.ModifyList(futureEventModifyList)
}
}
//处理获取积分榜数据
func (this *BaseFaceProcesser) score_process(matchId string, p *page.Page) []interface{} {
data_list_slice := make([]interface{}, 0)
elem_table := p.GetHtmlParser().Find(" table.mytable")
func (this *BaseFaceProcesser) score_process(matchId string, p *page.Page) []*pojo.BFScore {
data_list_slice := make([]*pojo.BFScore, 0)
elem_table := p.GetHtmlParser().Find(" div.fenxiBar:contains('联赛积分排名')~table.mytable")
elem_table.EachWithBreak(func(i int, selection *goquery.Selection) bool {
//只取前两个table
if i > 1 {
......@@ -92,31 +140,29 @@ func (this *BaseFaceProcesser) score_process(matchId string, p *page.Page) []int
prev := selection.Prev()
tempTeamId := strings.TrimSpace(prev.Text())
selection.Find(" tr ").Each(func(i int, selection *goquery.Selection) {
if i >= 1 {
val_arr := make([]string, 0)
selection.Children().Each(func(i int, selection *goquery.Selection) {
val := selection.Text()
val_arr = append(val_arr, strings.TrimSpace(val))
})
temp := new(pojo.BFScore)
temp.MatchId = matchId
temp.TeamId = tempTeamId
temp.Type = val_arr[0]
temp.MatchCount, _ = strconv.Atoi(val_arr[1])
temp.WinCount, _ = strconv.Atoi(val_arr[2])
temp.DrawCount, _ = strconv.Atoi(val_arr[3])
temp.FailCount, _ = strconv.Atoi(val_arr[4])
temp.GetGoal, _ = strconv.Atoi(val_arr[5])
temp.LossGoal, _ = strconv.Atoi(val_arr[6])
temp.DiffGoal, _ = strconv.Atoi(val_arr[7])
temp.Score, _ = strconv.Atoi(val_arr[8])
temp.Ranking, _ = strconv.Atoi(val_arr[9])
temp_val := strings.Replace(val_arr[10], "%", "", 1)
temp.WinRate, _ = strconv.ParseFloat(temp_val, 64)
data_list_slice = append(data_list_slice, temp)
}
selection.Find(" tr[align=center] ").Each(func(i int, selection *goquery.Selection) {
val_arr := make([]string, 0)
selection.Children().Each(func(i int, selection *goquery.Selection) {
val := selection.Text()
val_arr = append(val_arr, strings.TrimSpace(val))
})
temp := new(pojo.BFScore)
temp.MatchId = matchId
temp.TeamId = tempTeamId
temp.Type = val_arr[0]
temp.MatchCount, _ = strconv.Atoi(val_arr[1])
temp.WinCount, _ = strconv.Atoi(val_arr[2])
temp.DrawCount, _ = strconv.Atoi(val_arr[3])
temp.FailCount, _ = strconv.Atoi(val_arr[4])
temp.GetGoal, _ = strconv.Atoi(val_arr[5])
temp.LossGoal, _ = strconv.Atoi(val_arr[6])
temp.DiffGoal, _ = strconv.Atoi(val_arr[7])
temp.Score, _ = strconv.Atoi(val_arr[8])
temp.Ranking, _ = strconv.Atoi(val_arr[9])
temp_val := strings.Replace(val_arr[10], "%", "", 1)
temp.WinRate, _ = strconv.ParseFloat(temp_val, 64)
data_list_slice = append(data_list_slice, temp)
})
return true
})
......@@ -124,8 +170,8 @@ func (this *BaseFaceProcesser) score_process(matchId string, p *page.Page) []int
}
//处理对战数据获取
func (this *BaseFaceProcesser) battle_process(matchId string, p *page.Page) []interface{} {
data_list_slice := make([]interface{}, 0)
func (this *BaseFaceProcesser) battle_process(matchId string, p *page.Page) []*pojo.BFBattle {
data_list_slice := make([]*pojo.BFBattle, 0)
var hdata_str string
p.GetHtmlParser().Find("script").Each(func(i int, selection *goquery.Selection) {
......@@ -144,7 +190,6 @@ func (this *BaseFaceProcesser) battle_process(matchId string, p *page.Page) []in
temp_arr := strings.Split(hdata_str, "var vsTeamInfo = ")
temp_arr = strings.Split(temp_arr[1], ";")
hdata_str = strings.TrimSpace(temp_arr[0])
base.Log.Info(hdata_str)
var hdata_list = make([]*vo.BattleData, 0)
json.Unmarshal(([]byte)(hdata_str), &hdata_list)
......@@ -174,42 +219,42 @@ func (this *BaseFaceProcesser) battle_process(matchId string, p *page.Page) []in
}
//处理获取示来对战数据
func (this *BaseFaceProcesser) future_event_process(matchId string, p *page.Page) []interface{} {
data_list_slice := make([]interface{}, 0)
elem_table := p.GetHtmlParser().Find(" table.mytable")
elem_table_len := len(elem_table.Nodes)
func (this *BaseFaceProcesser) future_event_process(matchId string, p *page.Page) []*pojo.BFFutureEvent {
data_list_slice := make([]*pojo.BFFutureEvent, 0)
elem_table := p.GetHtmlParser().Find(" div.fenxiBar:contains('未来三场')~table.mytable")
elem_table.Each(func(i int, selection *goquery.Selection) {
//只取倒数2,3个table
if i < (elem_table_len-3) || i == (elem_table_len-1) {
if i > 1 {
return
}
prev := selection.Prev()
tempTeamId := strings.TrimSpace(prev.Text())
selection.Find(" tr ").Each(func(i int, selection *goquery.Selection) {
if i >= 1 {
val_arr := make([]string, 0)
selection.Children().Each(func(i int, selection *goquery.Selection) {
if i == 0 {
selection.Find("div").Each(func(i int, selection *goquery.Selection) {
val := selection.Text()
val_arr = append(val_arr, strings.TrimSpace(val))
})
} else {
selection.Find(" tr[align=center] ").Each(func(i int, selection *goquery.Selection) {
val_arr := make([]string, 0)
selection.Children().Each(func(i int, selection *goquery.Selection) {
if i == 0 {
selection.Find("div").Each(func(i int, selection *goquery.Selection) {
val := selection.Text()
val_arr = append(val_arr, strings.TrimSpace(val))
}
})
temp := new(pojo.BFFutureEvent)
temp.MatchId = matchId
temp.EventMatchDate, _ = time.ParseInLocation("2006-01-02", val_arr[0], time.Local)
temp.EventLeagueId = val_arr[1]
temp.EventMainTeamId = val_arr[2]
temp.EventGuestTeamId = val_arr[3]
temp_val := strings.Replace(val_arr[4], "天", "", 1)
temp.IntervalDay, _ = strconv.Atoi(temp_val)
data_list_slice = append(data_list_slice, temp)
}
})
} else {
val := selection.Text()
val_arr = append(val_arr, strings.TrimSpace(val))
}
})
temp := new(pojo.BFFutureEvent)
temp.MatchId = matchId
temp.TeamId = tempTeamId
temp.EventMatchDate, _ = time.ParseInLocation("2006-01-02", val_arr[0], time.Local)
temp.EventLeagueId = val_arr[1]
temp.EventMainTeamId = val_arr[2]
temp.EventGuestTeamId = val_arr[3]
temp_val := strings.Replace(val_arr[4], "天", "", 1)
temp.IntervalDay, _ = strconv.Atoi(temp_val)
data_list_slice = append(data_list_slice, temp)
})
})
return data_list_slice
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册