public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; SeasonTableParam param = bd.Param as SeasonTableParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); var root = GetHtmlRoot(cdata[10]); var wrap = root.SelectSingleNode("//div[@class='multiview_wrap']"); if (wrap == null || wrap.ChildNodes == null) { return; } var tableId = RegexGetStr(wrap.ChildNodes[0].OuterHtml, "tableid','", "',"); var tableName = wrap.ChildNodes[0].InnerText; var ti = SeasonTableInfoManager.AddOrGetCacheEntity <SeasonTableInfo>(tableId); ti.CompareSet(tableId, tableName); // 解析小组积分 var tbody = wrap.SelectSingleNode("table/tbody"); List <SeasonTableRank> list = new List <SeasonTableRank>(); foreach (var tr in tbody.ChildNodes) { var count = tr.ChildNodes.Count; var points = tr.ChildNodes[count - 2].InnerText; var description = tr.ChildNodes[count - 1].InnerText; var teamId = RegexGetStr(tr.ChildNodes[2].InnerHtml, "teamid','", "',"); var rank = new SeasonTableRank() { TeamId = teamId, TableId = tableId, TeamPoints = points, Description = description }; list.Add(rank); } ti.CompareTableRank(list); }
public void Process(ITakerReptile.Dto.BaseData data) { // 解析队伍伤停人员缓存到TeamPlayers中 BRData bd = data as BRData; InjuryParam param = bd.Param as InjuryParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValue(cdataFlag); if (string.IsNullOrEmpty(cdata)) { return; } var root = GetHtmlRoot(cdata); var tbody = root.SelectSingleNode("//tbody"); List <InjurePlayer> list = new List <InjurePlayer>(); foreach (var node in tbody.ChildNodes) { var player = node.SelectSingleNode("td[@class='player']"); if (player == null) { continue; } InjurePlayer injure = new InjurePlayer(); injure.PlayerId = RegexGetStr(player.InnerHtml, "playerid', '", "',"); injure.Missing = node.SelectSingleNode("td[@class='missing']").InnerText; injure.Status = node.SelectSingleNode("td[@class='reason ']").InnerText; list.Add(injure); } var tp = TeamPlayersManager.AddOrGetCacheEntity <TeamPlayers>(param.TeamId + "_" + param.SeasonId); tp.CompareSetInjurePlayerList(list); }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; SeasonTypeParam param = bd.Param as SeasonTypeParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); }
// 解析转会记录,缓存到PlayerEntity中 public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; PlayerTransferParam param = bd.Param as PlayerTransferParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValue(cdataFlag); if (string.IsNullOrEmpty(cdata)) { return; } var root = GetHtmlRoot(cdata); var tbody = root.SelectSingleNode("//tbody"); var player = PlayerEntityManager.AddOrGetCacheEntity <PlayerEntity>(param.PlayerId); foreach (var node in tbody.ChildNodes) { TransferHistory th = new TransferHistory(); th.TeamId = RegexGetStr(node.ChildNodes[0].InnerHtml, "teamid','", "',"); th.DuringTime = node.ChildNodes[1].InnerText; th.Description = node.ChildNodes[2].InnerText; player.CompareSetTransferHistory(th); } }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; TeamParam param = bd.Param as TeamParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); // 解析队伍基本信息 TeamEntity te = new TeamEntity(); te.TeamId = param.TeamId; te.Mark = "https://ls.betradar.com/ls/crest/big/" + param.TeamId + ".png"; var teamInfo = cdata[2]; var root = GetHtmlRoot(teamInfo); var teamName = root.SelectSingleNode("//thead/tr").InnerText; te.TeamName = teamName; var trsTeam = root.SelectNodes("//tbody/tr"); if (trsTeam.Count == 2) { te.Manager = trsTeam[1].LastChild.InnerText; } else if (trsTeam.Count > 2) { te.Manager = trsTeam[1].LastChild.InnerText; te.Venue = trsTeam[2].LastChild.InnerText; } var teamEntity = TeamEntityManager.AddOrGetCacheEntity <TeamEntity>(te.TeamId); teamEntity.CompareSetTeamEntity(te); #region 队伍球员相关信息 // 解析进球数获得队员的点球个数,更新到队员点球信息缓存中 if (cdata.Count < 16) { return; // 此队伍无队员信息,克罗地亚乙级联赛->卢科 } var penGoals = GetDataLikeKey(cdata, "normaltable toplist"); if (string.IsNullOrEmpty(penGoals)) { return; } root = GetHtmlRoot(penGoals); var trsPenGoals = root.SelectNodes("//tbody/tr"); if (trsPenGoals != null) { foreach (var tr in trsPenGoals) { var player = tr.SelectSingleNode("td[@class='player']"); if (player == null) { continue; } var playerId = RegexGetStr(player.InnerHtml, "playerid', '", "',"); var pen = tr.LastChild.InnerText; PlayerPenalties pp = PlayerPenaltiesManager.AddOrGetCacheEntity <PlayerPenalties>(playerId + "_" + param.SeasonId); pp.PlayerId = playerId; pp.SeasonId = param.SeasonId; pp.ComparePlayerPenalties(pen); } } // 解析全部名单,并添加球员任务 var playersData = cdata.FirstOrDefault(o => o.Contains("teampage_squad")); if (playersData == null) { return; } root = GetHtmlRoot(playersData); var trsPlayer = root.SelectNodes("//tbody/tr"); if (trsPlayer != null) { List <string> list = new List <string>(); foreach (var tr in trsPlayer) { var s = tr.Attributes["onclick"].Value; var playerId = RegexGetStr(s, "playerid', '", "',"); list.Add(playerId); } var tp = TeamPlayersManager.AddOrGetCacheEntity <TeamPlayers>(param.TeamId + "_" + param.SeasonId); tp.TeamId = param.TeamId; tp.SeasonId = param.SeasonId; var dic = tp.CompareSetPlayerIdList(list); NextAssignTask(param, dic); } #endregion // 如果有添加获取伤停的任务 if (txt.IndexOf("o=\"1003\"") > 0) { InjuryParam ip = param.CopyCreateParam <InjuryParam>(); LeagueManager.AddOrUpdateParam(ip); } }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; SeasonParam param = bd.Param as SeasonParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } // 首先添加联赛层级的比赛任务 MatchParam mp = param.CopyCreateParam <MatchParam>(); LeagueManager.AddOrUpdateParam(mp); if (param.CurrentUrlKey == "tableIds") { ProcessTableIdsTxt(param, txt); return; } else if (param.CurrentUrlKey == "teamIds") { ProcessTeamIdsTxt(param, txt); return; } var xml = new XmlHelper(txt); // 获取赛季名称 var title = xml.GetAttributeValue("//page", "title"); var seasonName = title.Split('>').Last(); SeasonEntity currentSeasonEntity = new SeasonEntity(); currentSeasonEntity.SportId = param.SportId; currentSeasonEntity.SeasonId = param.SeasonId; currentSeasonEntity.SeasonName = seasonName; // 获取积分数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); if (cdata.Count == 0) { // 杯赛没有积分数据的,添加获取所有队伍Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("teamIds"); LeagueManager.AddOrUpdateParam(param); return; } var teamRankData = ""; if (cdata.Count > 5) { teamRankData = cdata[4]; } if (string.IsNullOrEmpty(teamRankData)) { return; } var currentRound = RegexGetStr(cdata[0], "sb-current\"><div class=\"label\">", "<"); currentSeasonEntity.CurrentRound = currentRound; SeasonEntity se = SeasonEntityManager.AddOrGetCacheEntity <SeasonEntity>(param.SeasonId); se.CompareSetSeasonInfo(currentSeasonEntity); // 解析积分数据,并添加队伍任务,添加队伍积分数据,其他数据可由已经结束的比赛结果计算 List <string> teamIdList = new List <string>(); List <SeasonTeamRank> trList = new List <SeasonTeamRank>(); var root = GetHtmlRoot(teamRankData); var tables = root.SelectNodes("//table[@class='normaltable']/tbody"); if (tables.Count == 0) { return; } if (tables.Count > 1) { // 多个积分榜数据,有分组别的,添加获取所有组别Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("tableIds"); LeagueManager.AddOrUpdateParam(param); // 同时添加获取全部队伍Id的任务 param = param.CopyCreateParam <SeasonParam>(); param.SetCurrentUrlKey("teamIds"); LeagueManager.AddOrUpdateParam(param); return; } foreach (var node in tables[0].ChildNodes) { var teamId = RegexGetStr(node.ChildNodes[2].InnerHtml, "teamid','", "',"); teamIdList.Add(teamId); var trDataArr = node.ChildNodes.Select(o => o.InnerText).ToArray(); SeasonTeamRank tr = new SeasonTeamRank() { SeasonId = param.SeasonId, TeamId = teamId, TeamPoints = trDataArr[11], Description = trDataArr[12] }; trList.Add(tr); } SeasonTeams st = SeasonTeamsManager.AddOrGetCacheEntity <SeasonTeams>(param.SeasonId); st.CompareSetTeamRank(trList); // 要分配的队伍任务 var teamTaskDic = se.CompareSetTeamIdList(teamIdList); TeamAssignTask(param, teamTaskDic); }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; MatchParam param = bd.Param as MatchParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); // 获取历史赛季Id,添加到联赛任务,只抓取一次 var historySeasonIdData = GetDataLikeKey(cdata, "sb-wrapper", "lang-1"); var seasonIdList = new List <string>(); if (historySeasonIdData != null) { var rootHistory = GetHtmlRoot(historySeasonIdData); var ul = rootHistory.SelectSingleNode("//div[@class='sb-scrollbox']/ul"); foreach (var li in ul.ChildNodes) { var id = RegexGetStr(li.OuterHtml, "'5_", ","); seasonIdList.Add(id); var sp = param.CopyCreateParam <SeasonParam>(); sp.IsHistoryParam = true; sp.SeasonId = id; LeagueManager.AddOrUpdateParam(sp); } } if (!param.IsHistoryParam && seasonIdList.Any()) { var le = LeagueEntityManager.AddOrGetCacheEntity <LeagueEntity>(param.SeasonId); le.CompareSetSeasonIds(seasonIdList); } // 解析比赛 var matchData = GetDataLikeKey(cdata, "normaltable fixtures"); if (string.IsNullOrEmpty(matchData)) { return; } var root = GetHtmlRoot(matchData); bool isTitle = true; string round = ""; foreach (var node in root.ChildNodes) { switch (node.Name) { case "#text": continue; case "h2": if (isTitle) { isTitle = false; } else { round = node.InnerText; } continue; case "table": ParseMatch(round, node, param); continue; } } }
public void Process(ITakerReptile.Dto.BaseData data) { BRData bd = data as BRData; PlayerParam param = bd.Param as PlayerParam; CheckSetHistoryParam(param); string txt; if (!HtmlDecode(bd.Html, out txt)) { return; } var xml = new XmlHelper(txt); // 解析成各个数据块 var cdataFlag = "//c"; var cdata = xml.GetValues(cdataFlag); // 解析球员基本信息 var playerInfo = cdata[1]; var root = GetHtmlRoot(playerInfo); var tbody = root.SelectSingleNode("//div[@class='multiview_wrap']/table/tbody"); Dictionary <string, string> infoDic = new Dictionary <string, string>(); foreach (var node in tbody.ChildNodes) { infoDic.Add(node.ChildNodes[0].InnerText, node.ChildNodes[1].InnerText); } var currentPlayerEntity = new PlayerEntity() { PlayerId = param.PlayerId }; foreach (var info in infoDic) { switch (info.Key) { case "全名:": case "姓名:": case "Full name:": case "Name:": currentPlayerEntity.FullName = info.Value; break; case "国家:": case "Country:": currentPlayerEntity.Country = info.Value; break; case "第二国籍:": case "Secondary country:": currentPlayerEntity.SecondaryCountry = info.Value; break; case "出生日期:": case "Date of birth:": currentPlayerEntity.Birth = info.Value; break; case "年龄:": case "Age:": currentPlayerEntity.Age = info.Value; break; case "身高:": case "Height:": currentPlayerEntity.Height = info.Value; break; case "体重:": case "Weight:": currentPlayerEntity.Weight = info.Value; break; case "位置:": case "Position:": currentPlayerEntity.Position = info.Value; break; case "球衣号码:": case "Shirt number:": currentPlayerEntity.ShirtNumber = info.Value; break; case "球队:": case "Team:": currentPlayerEntity.TeamName = info.Value; break; case "惯用脚:": case "Preferred foot:": currentPlayerEntity.PreferredFoot = info.Value; break; } } var pe = PlayerEntityManager.AddOrGetCacheEntity <PlayerEntity>(param.PlayerId); pe.CompareSetInfo(currentPlayerEntity); // 解析全部参赛记录 // 记录比赛Id // 缓存出场信息PlayerTimeRecord // 缓存进球,牌,助攻信息PlayerStatisticsRecord var recordData = cdata[2]; root = GetHtmlRoot(recordData); var tbodys = root.SelectNodes("//tbody"); foreach (var tb in tbodys) { foreach (var node in tb.ChildNodes) { var scoreStr = node.SelectSingleNode("td[@class='score']"); if (scoreStr == null || string.IsNullOrEmpty(scoreStr.InnerHtml)) { continue; } var matchId = RegexGetStr(scoreStr.InnerHtml, "matchid','", "\'"); var nowPsr = new PlayerStatisticsRecord(); nowPsr.MatchId = matchId; nowPsr.PlayerId = param.PlayerId; nowPsr.Goals = Convert.ToInt32(node.SelectSingleNode("td[@class='goals']").InnerText); var assists = node.SelectSingleNode("td[@class='assists']"); nowPsr.Assists = assists == null ? 0 : Convert.ToInt32(assists.InnerText); nowPsr.YellowCard = Convert.ToInt32(node.SelectSingleNode("td[@class='yellow']").InnerText); nowPsr.YellowRedCard = Convert.ToInt32(node.SelectSingleNode("td[@class='yellowred']").InnerText); nowPsr.RedCard = Convert.ToInt32(node.SelectSingleNode("td[@class='red last']").InnerText); var psr = PlayerStatisticsRecordManager.AddOrGetCacheEntity <PlayerStatisticsRecord>(param.PlayerId + "_" + matchId); psr.CompareSet(nowPsr); var nowPtr = new PlayerTimeRecord(); nowPtr.MatchId = matchId; nowPtr.PlayerId = param.PlayerId; nowPtr.IsStarting = Convert.ToInt32(node.SelectSingleNode("td[@class='started']").InnerText) == 1; nowPtr.IsInPlay = Convert.ToInt32(node.SelectSingleNode("td[@class='in']").InnerText) == 1; nowPtr.IsOutPlay = Convert.ToInt32(node.SelectSingleNode("td[@class='out']").InnerText) == 1; nowPtr.MinutesPlayed = Convert.ToInt32(node.SelectSingleNode("td[@class='min']").InnerText); var ptr = PlayerTimeRecordManager.AddOrGetCacheEntity <PlayerTimeRecord>(param.PlayerId + "_" + matchId); ptr.CompareSet(nowPtr); } } // 如果有添加获取转会记录的任务 if (txt.IndexOf("o=\"2\"") > 0) { PlayerTransferParam ptParam = param.CopyCreateParam <PlayerTransferParam>(); PlayerManager.AddOrUpdateParam(ptParam); } }