private List <NumberInfo> GetNumbers(DownParameter param, int endIndex) { string url = string.Empty; List <NumberInfo> numbers = new List <NumberInfo>(endIndex * 40); for (int i = endIndex; i >= 1; i--) { try { url = string.Format(param.Category.DownUrl, i, param.Category.Code, "", param.Category.Name, param.Category.IsGP); string pageText = this._webClient.DownloadString(url); var pageNumbers = this.ExtractNumbers(pageText); if (pageNumbers.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); break; } numbers.AddRange(pageNumbers); } catch (Exception ex) { Logger.Instance.Write(string.Format("url:{0},message:{1}", url, ex)); break; } } return(numbers); }
protected override bool Down3D(DownParameter param) { SQLServer.D3.DwNumberBiz biz = new SQLServer.D3.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) return false; var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) return false; long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { char[] digits = numberInfo.Number.ToArray(); string code = string.Join(",", digits); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) continue; if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) continue; return false; } return true; }
protected override bool Down3D(DownParameter param) { Biz.D3.DwNumberBiz biz = new Biz.D3.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); var numbers = this.GetNumbers(param, lastDate); if (numbers.Count == 0) { return(false); } long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number; DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) { continue; } if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) { continue; } return(false); } return(true); }
private List <NumberInfo> GetNumbers(DownParameter param, DateTime lastDate) { string url = string.Empty; List <NumberInfo> numbers = new List <NumberInfo>(120); for (DateTime currDate = lastDate; currDate <= DateTime.Now; currDate = currDate.AddDays(1)) { try { url = string.Format(param.Category.DownUrl, currDate.ToString("yyyy-MM-dd")); this._webClient.Encoding = System.Text.Encoding.UTF8; string userAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)"; this._webClient.Headers.Add("User-Agent", userAgent); string pageText = this._webClient.DownloadString(url); var pageNumbers = this.ExtractNumbers(pageText, param.Category.DbName); if (pageNumbers.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); //break; } numbers.AddRange(pageNumbers); } catch (Exception ex) { Logger.Instance.Write(string.Format("url:{0},message:{1}", url, ex)); break; } } return(numbers); }
public virtual bool Down(DownParameter param) { string type = param.Category.Type.ToLower(); if (type.Equals("11x5")) { return(this.Down11X5(param)); } if (type.Equals("ssc")) { return(this.DownSSC(param)); } if (type.Equals("3d")) { return(this.Down3D(param)); } if (type.Equals("pl35")) { return(this.DownPL35(param)); } if (type.Equals("ssl")) { return(this.DownSSL(param)); } if (type.Equals("12x3")) { return(this.Down12X3(param)); } return(false); }
protected override bool Down11X5(DownParameter param) { SQLServer.D11X5.DwNumberBiz biz = new SQLServer.D11X5.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) return false; var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) return false; long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number.Replace(" ", ","); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); int p = 2000000000 + int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 2)); if (p <= lastP) continue; if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) continue; return false; } return true; }
private bool DownSSC(DownParameter param, SQLServer.SSC.DwNumberBiz biz, DateTime currentDate) { int intDate = int.Parse(currentDate.ToString("yyyyMMdd")); string url = string.Format(param.Category.DownUrl, "&", intDate); try { string htmlText = this._webClient.DownloadString(url); MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return(false); } long lastP = biz.GetLatestPeroid(); //HashSet<long> pSet = biz.GetPeroidsByDate(currentDate); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, "<div class=\"numBall_ssc\">(.*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); code = Regex.Replace(code, "<.*?>|[\\s]", "").Trim(); if (string.IsNullOrEmpty(code) || code.Length == 0) { continue; } long p = long.Parse(peroid); //把期号统一成{yyyymmddnnn} if (p < 20000000000) { p += 20000000000; } //if (pSet.Contains(p)) continue; if (p <= lastP) { continue; } code = string.Join(",", code.ToArray()); int n = int.Parse(peroid.Substring(peroid.Length - 3)); if (!biz.Add(p, n, code, intDate, datetime)) { return(false); } } return(true); } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return(false); } }
private bool Down11X5(DownParameter param, SQLServer.D11X5.DwNumberBiz biz, DateTime currentDate) { int intDate = int.Parse(currentDate.ToString("yyyyMMdd")); string url = string.Format(param.Category.DownUrl, intDate, "&"); try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<tbody id=\"row_show\">.*</tbody>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value; MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return(false); } long lastP = biz.GetLatestPeroid(); //HashSet<long> pSet = biz.GetPeroidsByDate(currentDate); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, @"[<spans >|<span >](\d{2},\d{2},\d{2},\d{2},\d{2})[</spans>|<spans>]", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) { continue; } int p = int.Parse(peroid); //把期号统一成{yyyymmddnn} if (p < 2000000000) { p += 2000000000; } //if (pSet.Contains(p)) continue; if (p <= lastP) { continue; } int n = int.Parse(peroid.Substring(peroid.Length - 2)); if (!biz.Add(p, n, code, intDate, datetime)) { return(false); } } return(true); } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return(false); } }
private bool DownPL35(DownParameter param, Biz.PL35.DwNumberBiz biz, DateTime currentDate) { string url = param.Category.DownUrl; try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<div id=\"conKjlist\" class=\"kjlist\">.*?</table>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value; MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return(false); } long lastP = biz.GetLatestPeroid(); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td>(\\d{7})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td>(\\d{4}-\\d{2}-\\d{2})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, "<div class=\"aball\">.*?</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Value; code = Regex.Replace(code, "<.*?>", ""); code = string.Join(",", code.ToArray()); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) { continue; } int intDate = int.Parse(datetime.Replace("-", "")); int p = int.Parse(peroid); //把期号统一成{yyyynnn} if (p < 2000000) { p += 2000000; } if (p <= lastP) { continue; } int n = int.Parse(peroid.Substring(peroid.Length - 3)); if (!biz.Add(p, n, code, intDate, datetime)) { return(false); } } return(true); } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return(false); } }
protected override bool DownSSC(DownParameter param) { SQLServer.SSC.DwNumberBiz biz = new SQLServer.SSC.DwNumberBiz(param.Category.DbName); DateTime startDate = biz.GetLatestDate(); for (DateTime date = startDate; date <= DateTime.Now; date = date.AddDays(1)) { if (!this.DownSSC(param, biz, date)) return false; } return true; }
public virtual bool Down(DownParameter param) { string type = param.Category.Type.ToLower(); if (type.Equals("11x5")) return this.Down11X5(param); if (type.Equals("ssc")) return this.DownSSC(param); if (type.Equals("3d")) return this.Down3D(param); if (type.Equals("pl35")) return this.DownPL35(param); if (type.Equals("ssl")) return this.DownSSL(param); if (type.Equals("12x3")) return this.Down12X3(param); return false; }
private void StartDown(EventParameter eventParameter) { IDownloader downloader = DownloaderFactory.Creator(eventParameter.Category.DownUrl); if (downloader == null) { return; } DownParameter downParameter = new DownParameter(eventParameter.Category); downloader.Down(downParameter); }
protected override bool DownSSC(DownParameter param) { SQLServer.SSC.DwNumberBiz biz = new SQLServer.SSC.DwNumberBiz(param.Category.DbName); DateTime startDate = biz.GetLatestDate(); for (DateTime date = startDate; date <= DateTime.Now; date = date.AddDays(1)) { if (!this.DownSSC(param, biz, date)) { return(false); } } return(true); }
private bool Down11X5(DownParameter param, SQLServer.D11X5.DwNumberBiz biz, DateTime currentDate) { int intDate = int.Parse(currentDate.ToString("yyyyMMdd")); string url = string.Format(param.Category.DownUrl, intDate, "&"); try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<tbody id=\"row_show\">.*</tbody>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value; MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return false; } long lastP = biz.GetLatestPeroid(); //HashSet<long> pSet = biz.GetPeroidsByDate(currentDate); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, @"[<spans >|<span >](\d{2},\d{2},\d{2},\d{2},\d{2})[</spans>|<spans>]", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) continue; int p = int.Parse(peroid); //把期号统一成{yyyymmddnn} if (p < 2000000000) p += 2000000000; //if (pSet.Contains(p)) continue; if (p <= lastP) continue; int n = int.Parse(peroid.Substring(peroid.Length - 2)); if (!biz.Add(p, n, code, intDate, datetime)) return false; } return true; } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return false; } }
private bool Down3D(DownParameter param, SQLServer.D3.DwNumberBiz biz, DateTime currentDate) { string url = param.Category.DownUrl; try { string htmlText = Regex.Match(this._webClient.DownloadString(url), "<div id=\"conKjlist\" class=\"kjlist\">.*?</table>", RegexOptions.Singleline | RegexOptions.IgnoreCase).Value; MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return false; } long lastP = biz.GetLatestPeroid(); //HashSet<long> pSet = biz.GetPeroidsByDate(currentDate); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td>(\\d{7})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td>(\\d{4}-\\d{2}-\\d{2})</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, "<div class=\"aball\">.*?</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Value; code = Regex.Replace(code, "<.*?>", ""); code = string.Join(",", code.ToArray()); if (string.IsNullOrEmpty(code) || code.Trim().Length == 0) continue; int intDate = int.Parse(datetime.Replace("-", "")); int p = int.Parse(peroid); //把期号统一成{yyyynnn} if (p < 2000000) p += 2000000; //if (pSet.Contains(p)) continue; if (p <= lastP) continue; int n = int.Parse(peroid.Substring(peroid.Length - 3)); if (!biz.Add(p, n, code, intDate, datetime)) return false; } return true; } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return false; } }
protected override bool DownSSC(DownParameter param) { Biz.SSC.DwNumberBiz biz = new Biz.SSC.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) { return(false); } var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) { return(false); } long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { char[] digits = numberInfo.Number.ToArray(); string code = string.Join(",", digits); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = 20000000000 + int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) { continue; } if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) { continue; } return(false); } return(true); }
protected override bool Down12X3(DownParameter param) { SQLServer.D12X3.DwNumberBiz biz = new SQLServer.D12X3.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); int endIndex = this.GetEndIndex(param, lastDate); if (endIndex <= 0) { return(false); } var numbers = this.GetNumbers(param, endIndex); if (numbers.Count == 0) { return(false); } long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number.Replace(" ", ","); DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); int p = 2000000000 + int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 2)); if (p <= lastP) { continue; } if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) { continue; } return(false); } return(true); }
private int GetEndIndex(DownParameter param, DateTime lastDate) { int endIndex = 0; DateTime currentDate = lastDate; try { string url = string.Format(param.Category.DownUrl, 1, param.Category.Code, "", param.Category.Name, param.Category.IsGP); string pageText = this._webClient.DownloadString(url); pageText = pageText.Replace("&", "&").Replace(""", "\"").Replace("<", "<").Replace(">", ">"); string pattern = "<tr style='background-color: White; border-color: #B6CBE8;'>.*?</tr>"; MatchCollection matches = Regex.Matches(pageText, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (Match m in matches) { string sdate = Regex.Match(m.Value, "<td align='center' style='width: 20%;'>(.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(m.Value, "'MyGridView_ctl02_lblHao'>(.*?)</(spans|span)>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); if (code.Trim().Length == 0) { continue; } currentDate = DateTime.Parse(sdate); break; } TimeSpan timeSpan = currentDate - lastDate; int days = timeSpan.Days + 1; int count = days * param.Category.Times; endIndex = (count / param.Category.DownPageSize) + 1; } catch (Exception ex) { Logger.Instance.Write(string.Format("ex:{0},message:{1}", ex, "获取EndIndex失败")); } return(endIndex); }
protected override bool Down3D(DownParameter param) { Biz.D3.DwNumberBiz biz = new Biz.D3.DwNumberBiz(param.Category.DbName); DateTime lastDate = biz.GetLatestDate(); var numbers = this.GetNumbers(param, lastDate); if (numbers.Count == 0) return false; long lastP = biz.GetLatestPeroid(); foreach (var numberInfo in numbers) { string code = numberInfo.Number; DateTime datetime = DateTime.Parse(numberInfo.DateTime); int dateint = int.Parse(datetime.ToString("yyyyMMdd")); long p = int.Parse(numberInfo.Peroid); int n = int.Parse(numberInfo.Peroid.Substring(numberInfo.Peroid.Length - 3)); if (p <= lastP) continue; if (biz.Add(p, n, code, dateint, numberInfo.DateTime)) continue; return false; } return true; }
private List<NumberInfo> GetNumbers(DownParameter param,DateTime lastDate) { string url = string.Empty; List<NumberInfo> numbers = new List<NumberInfo>(120); for (DateTime currDate = lastDate; currDate <= DateTime.Now;currDate=currDate.AddDays(1)) { try { url = string.Format(param.Category.DownUrl, currDate.ToString("yyyy-MM-dd")); this._webClient.Encoding = System.Text.Encoding.UTF8; string userAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)"; this._webClient.Headers.Add("User-Agent", userAgent); string pageText = this._webClient.DownloadString(url); var pageNumbers = this.ExtractNumbers(pageText,param.Category.DbName); if (pageNumbers.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); //break; } numbers.AddRange(pageNumbers); } catch (Exception ex) { Logger.Instance.Write(string.Format("url:{0},message:{1}", url, ex)); break; } } return numbers; }
protected virtual bool Down12X3(DownParameter param) { return(false); }
private List<NumberInfo> GetNumbers(DownParameter param,int endIndex) { string url = string.Empty; List<NumberInfo> numbers = new List<NumberInfo>(endIndex * 40); for (int i = endIndex; i >= 1; i--) { try { url = string.Format(param.Category.DownUrl, i, param.Category.Code, "", param.Category.Name, param.Category.IsGP); string pageText = this._webClient.DownloadString(url); var pageNumbers = this.ExtractNumbers(pageText); if (pageNumbers.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); break; } numbers.AddRange(pageNumbers); } catch (Exception ex) { Logger.Instance.Write(string.Format("url:{0},message:{1}", url, ex)); break; } } return numbers; }
private int GetEndIndex(DownParameter param,DateTime lastDate) { int endIndex = 0; DateTime currentDate = lastDate; try { string url = string.Format(param.Category.DownUrl, 1, param.Category.Code, "", param.Category.Name, param.Category.IsGP); string pageText = this._webClient.DownloadString(url); pageText = pageText.Replace("&", "&").Replace(""", "\"").Replace("<", "<").Replace(">", ">"); string pattern = "<tr style='background-color: White; border-color: #B6CBE8;'>.*?</tr>"; MatchCollection matches = Regex.Matches(pageText, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase); foreach (Match m in matches) { string sdate = Regex.Match(m.Value, "<td align='center' style='width: 20%;'>(.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(m.Value, "'MyGridView_ctl02_lblHao'>(.*?)</(spans|span)>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); if (code.Trim().Length == 0) continue; currentDate = DateTime.Parse(sdate); break; } TimeSpan timeSpan = currentDate - lastDate; int days = timeSpan.Days + 1; int count = days * param.Category.Times; endIndex = (count / param.Category.DownPageSize) + 1; } catch (Exception ex) { Logger.Instance.Write(string.Format("ex:{0},message:{1}", ex, "获取EndIndex失败")); } return endIndex; }
private bool DownSSC(DownParameter param, Biz.SSC.DwNumberBiz biz, DateTime currentDate) { int intDate = int.Parse(currentDate.ToString("yyyyMMdd")); string url = string.Format(param.Category.DownUrl, "&", intDate); try { string htmlText = this._webClient.DownloadString(url); MatchCollection matchs = Regex.Matches(htmlText, "<tr>.*?</tr>", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (matchs.Count == 0) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, "count=0")); return false; } long lastP = biz.GetLatestPeroid(); for (int i = matchs.Count - 1; i >= 0; i--) { Match match = matchs[i]; string peroid = Regex.Match(match.Value, "<td width=\"25%\">(\\d+)期</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string datetime = Regex.Match(match.Value, "<td width=\"25%\">(\\d{4}-\\d{2}-\\d{2}.*?)</td>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); string code = Regex.Match(match.Value, "<div class=\"numBall_ssc\">(.*?)</div>", RegexOptions.IgnoreCase | RegexOptions.Singleline).Groups[1].Value.Trim(); code = Regex.Replace(code, "<.*?>|[\\s]", "").Trim(); if (string.IsNullOrEmpty(code) || code.Length == 0) continue; long p = long.Parse(peroid); //把期号统一成{yyyymmddnnn} if (p < 20000000000) p += 20000000000; if (p <= lastP) continue; code = string.Join(",", code.ToArray()); int n = int.Parse(peroid.Substring(peroid.Length - 3)); if (!biz.Add(p, n, code, intDate, datetime)) return false; } return true; } catch (Exception ex) { Logger.Instance.Write(string.Format("name:{0},url:{1},msg:{2}", param.Category.Name, url, ex.Message)); return false; } }
private void StartDown(EventParameter eventParameter) { IDownloader downloader = DownloaderFactory.Creator(eventParameter.Category.DownUrl); if (downloader == null) return; DownParameter downParameter = new DownParameter(eventParameter.Category); downloader.Down(downParameter); }
protected virtual bool DownSSL(DownParameter param) { return false; }