public CaptainParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var cap = node .SelectNodes("table//tr[1]/td[2]/span")? .FirstOrDefault(n => (n.Attributes["class"]?.Value).Contains("kapitaenicon-table")); var parsedStr = (cap == null) ? "0" : "1"; return(new Captain { Value = Converter.Convert(parsedStr) }); }; }
public ClubArrivalDateParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node.InnerText; return(new ClubArrivalDate { Value = Converter.Convert(parsedStr) }); }; }
public ProfileUrlParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node .SelectNodes("table//td//a") .FirstOrDefault(n => n.Attributes["class"]?.Value == "spielprofil_tooltip") .Attributes["href"].Value; return(new ProfileUrl { Value = Converter.Convert(parsedStr) }); }; }
public ImgUrlParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node .SelectNodes("table//td/a/img") .FirstOrDefault(n => n.Attributes["class"]?.Value == "bilderrahmen-fixed") .Attributes["src"].Value; return(new ImgUrl { Value = Converter.Convert(parsedStr) }); }; }
public PositionParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node .SelectNodes("table//tr[2]/td[1]") .FirstOrDefault() .InnerText; return(new Position { Value = Converter.Convert(parsedStr) }); }; }
public HeightParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = Regex.Replace(node.InnerText, "([a-zA-Z,_ ]+|(?<=[a-zA-Z ])[/-])", ""); return(new Height { Value = Converter.Convert(parsedStr) }); }; }
public MarketValueParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { decimal?n = null; var sp = node.InnerText?.Split(new[] { " " }, StringSplitOptions.None); if (sp == null || sp.Length < 2) { throw new Exception("Invalid number of splits"); } var spl = sp[0].Split(new[] { "," }, StringSplitOptions.None); n = decimal.Parse(spl[0]); if (sp[1] == "M") { n = n * 1000000; } else if (sp[1] == "mil") { n = n * 1000; } return(new MarketValue { Value = Converter.Convert(n.ToString()) }); }; }
public ShirtNumberParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node .SelectNodes("div") .Where(n => n.Attributes["class"].Value == "rn_nummer") .FirstOrDefault() .InnerText; return(new ShirtNumber { Value = Converter.Convert(parsedStr) }); }; }
public NationalityParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node .SelectNodes("img") .Where(n => n.Attributes["class"]?.Value == "flaggenrahmen") .Select(n => n.Attributes["title"].Value)?.ToArray().FirstOrDefault().Trim(); return(new Nationality { Value = Converter.Convert(parsedStr) }); }; }
public BirthDateParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = node.InnerText?.Split(new[] { " (" }, StringSplitOptions.None)?[0]; return(new BirthDate { Value = Converter.Convert(parsedStr) }); }; }
public ContractExpirationDateParser() { this.CanParsePredicate = node => node?.InnerText?.Trim(Common.trimChars) == ParsersConfig.GetLabel(this.GetType(), ConfigType.PLAYER); this.ParseFunc = node => { var parsedStr = Regex.Replace(node.InnerText, @"\.", "/"); return(new ContractExpirationDate(DateTime.Now) { Value = Converter.Convert(parsedStr) }); }; }