public string get_data(string html) { StringBuilder sb = new StringBuilder(); HtmlAgilityPack.HtmlDocument doc_html = new HtmlAgilityPack.HtmlDocument(); doc_html.LoadHtml(html); HtmlNodeCollection nodes_all = doc_html.DocumentNode.SelectNodes(@"//*"); //string str_json = doc_html.DocumentNode.SELECT_NODE("/div[1]/div[1]/script[1]").InnerText.Replace("var centralAreaLiveSectionsJsonArray =", ""); string str_json = doc_html.DocumentNode.SELECT_NODE("/div[1]/div[2]/script[1]").InnerText.Replace("var centralAreaPreLiveSectionsJsonArray =", ""); BsonArray list_root = MongoHelper.get_array_from_str(str_json); foreach (BsonDocument root in list_root) { BsonArray matchs = root["matchesJsonArray"].AsBsonArray; foreach (BsonDocument match in matchs) { if (match.Contains("matchInfo")) { string date = match["matchInfo"]["sdfDMYTime"].ToString(); string time = match["matchInfo"]["sdfHourTime"].ToString(); string start_time = DateTime.Now.Year.ToString() + "-" + date.Substring(3, 2) + "-" + date.Substring(0, 2) + " " + time; string home = match["matchInfo"]["homeName"].ToString(); string away = match["matchInfo"]["awayName"].ToString(); string odd_home = match["marketWrapper"]["oddsJsonArray"][0]["ov"].ToString(); string odd_draw = match["marketWrapper"]["oddsJsonArray"][1]["ov"].ToString(); string odd_away = match["marketWrapper"]["oddsJsonArray"][2]["ov"].ToString(); sb.Append(start_time.PR(20) + home.PR(20) + away.PR(20) + odd_home.PR(10) + odd_draw.PR(10) + odd_away.PR(10) + M.N); Match100Helper.insert_data("betadonis", "", start_time, home, away, odd_home, odd_draw, odd_away, "2", "0"); } } } return(sb.ToString()); }
private void btn_read_to_names_Click(object sender, EventArgs e) { string sql = ""; sql = "select * from teams_log where website='90vs'"; DataTable dt = SQLServerHelper.get_table(sql); foreach (DataRow row in dt.Rows) { sql = "select * from names where name='{0}'"; sql = string.Format(sql, row["name1"].ToString()); if (SQLServerHelper.get_table(sql).Rows.Count == 0) { sql = "insert into names (name,name_all) values ( '{0}','{1}')"; sql = string.Format(sql, row["name1"].ToString(), Tool.drop_repeat(row["name_all"].ToString())); SQLServerHelper.exe_sql(sql); } } sql = " select * from teams_log where website='500'"; DataTable dt_500 = SQLServerHelper.get_table(sql); foreach (DataRow row in dt_500.Rows) { string name1 = row["name1"].ToString(); string name2 = row["name2"].ToString(); Match100Helper.insert_name(name1, name2); } MessageBox.Show("OK"); }
private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { WebBrowser browser = (WebBrowser)sender; string test = browser.Document.Url.ToString(); //res://ieframe.dll/navcancl.htm#D:\DOC\Visual Studio 2008\MyProjects\WebSite2\test.htm if (e.Url != browser.Document.Url) { return; } if (browser.ReadyState != WebBrowserReadyState.Complete) { return; } int index = Convert.ToInt32(browser.Name); int row_id = ies[index].row_id; if (dt.Rows[row_id]["select_type"].ToString() == "load") { dt.Rows[row_id]["end_time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); BsonDocument doc_result = Match100Helper.get_doc_result(); doc_result["data"] = "Load Complete!"; doc_result["url"] = browser.Document.Url.ToString(); ies[index].doc_result = doc_result; } }
public string get_data(string html) { StringBuilder sb = new StringBuilder(); html = html.Replace("<thead=\"\"", ""); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); List <HtmlNode> nodes = new List <HtmlNode>(); foreach (HtmlNode node in nodes_all) { if (node.Id == "tb2") { string team = node.SELECT_NODE("/div[1]/table[1]/tbody[1]/tr[1]/td[2]/a[1]/span[1]").InnerText; string[] teams = team.E_SPLIT("-"); string host = teams[0]; string client = teams[1]; string start_time = node.SELECT_NODE("/div[1]/table[1]/tbody[1]/tr[1]/td[3]").ChildNodes[0].InnerText.E_TRIM(); start_time = DateTime.Now.Year.ToString() + "-" + start_time.Substring(3, 2) + "-" + start_time.Substring(0, 2) + " " + start_time.Substring(6, 5); string odd_host = node.SELECT_NODE("/div[2]/table[1]/tbody[1]/tr[2]/td[1]").InnerText; string odd_draw = node.SELECT_NODE("/div[2]/table[1]/tbody[1]/tr[2]/td[2]").InnerText; string odd_away = node.SELECT_NODE("/div[2]/table[1]/tbody[1]/tr[2]/td[3]").InnerText; BsonDocument doc_odd = AnalyseTool.get_odd_doc_from_europe(odd_host, odd_draw, odd_away); sb.Append(host.PR(10) + client.PR(10) + start_time.PR(30) + odd_host.PR(10) + odd_draw.PR(10) + odd_away.PR(10) + doc_odd["persent_return"].ToString() + M.N); Match100Helper.insert_data("1-x-bet", "", start_time, host, client, odd_host, odd_draw, odd_away, "0", "0"); } } return(sb.ToString()); }
public void select_method_from_site(WebBrowser browser, int row_id) { int index = Convert.ToInt32(browser.Name); string method = dt.Rows[row_id]["method"].ToString(); string site_name = dt.Rows[row_id]["site_name"].ToString(); //invoke method Type reflect_type = Type.GetType("Match100Method"); object reflect_acvtive = Activator.CreateInstance(reflect_type, null); MethodInfo method_info = reflect_type.GetMethod(method); try { Match100Helper.create_log(method_info.Name, browser); } catch (Exception error) { } BsonDocument doc_input = ies[index].doc_result; BsonDocument doc_result = (BsonDocument)method_info.Invoke(reflect_acvtive, new object[] { browser, doc_input }); ies[index].doc_result = doc_result; //update grid dt.Rows[row_id]["end_time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); Application.DoEvents(); }
public static bool is_alike_name_by_db(string input1, string input2) { if (Match100Helper.convert_team_name(input1) == Match100Helper.convert_team_name(input2)) { return(true); } return(false); }
public void get_single_by_website_desc(List <BsonDocument> list) { StringBuilder sb = new StringBuilder(); sb.Append("BY website DESC:" + Environment.NewLine); DataTable dt = new DataTable(); DataColumn order = new DataColumn("order"); order.DataType = Type.GetType("System.Int32"); dt.Columns.Add(order); DataColumn count = new DataColumn("count"); count.DataType = Type.GetType("System.Int32"); dt.Columns.Add(count); for (int i = 0; i < list.Count; i++) { DataRow row_new = dt.NewRow(); row_new["order"] = i; BsonArray array = list[i]["websites"].AsBsonArray; ArrayList al = new ArrayList(); foreach (BsonValue value in array) { bool is_has = false; foreach (string name in al) { if (name == value.ToString()) { is_has = true; } } if (is_has == false) { al.Add(value.ToString()); } } row_new["count"] = al.Count; dt.Rows.Add(row_new); } dt.DefaultView.Sort = "count desc"; dt = dt.DefaultView.ToTable(); foreach (DataRow row in dt.Rows) { BsonDocument doc = list[Convert.ToInt32(row["order"].ToString())]; sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); sb.Append(Match100Analyse2.get_info_from_doc(doc)); } sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); this.txt_result.Text = sb.ToString(); Match100Helper.create_log_result(sb.ToString()); Application.DoEvents(); }
//methods public BsonDocument from_pinnaclesports_me_index(ref WebBrowser browser, BsonDocument doc_result) { doc_result = Match100Helper.get_doc_result(); string html = BrowserHelper.get_html(ref browser); StringBuilder sb = new StringBuilder(); //================================================================ BsonArray url1 = new BsonArray(); BsonArray url2 = new BsonArray(); html = html.Replace("<thead=\"\"", ""); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); List <HtmlNode> nodes = new List <HtmlNode>(); ArrayList list_lg = new ArrayList(); string str_class = ""; string name = ""; string href = ""; int count = 0; foreach (HtmlNode node in nodes_all) { if (node.Name == "div" && node.CLASS() == "clr") { str_class = node.InnerText; } if (node.Name == "li" && node.SELECT_NODES("/div") != null && node.SELECT_NODES("/div").Count == 2) { if (node.SELECT_NODE("/div[1]").CLASS() == "mea i") { name = node.SELECT_NODE("/div[2]").InnerText.E_REMOVE(); href = node.SELECT_NODE("/div[2]/a[1]").Attributes["href"].Value; if (str_class == "Soccer" && !name.Contains("Halfs") && !name.Contains("Totals") && !href.Contains("ContestCategory")) { count = count + 1; sb.AppendLine(count.PR(5) + str_class.PR(20) + name.PR(50) + href); url1.Add("http://www.pinnaclesports.com" + href); } } } } //=============================================================== doc_result["data"] = sb.ToString(); doc_result["url"] = browser.Document.Url.ToString(); doc_result.Add("url1", url1); doc_result.Add("url2", url2); return(doc_result); }
public string get_data2(string html) { StringBuilder sb = new StringBuilder(); html = html.Replace("<thead=\"\"", ""); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); List <HtmlNode> nodes = new List <HtmlNode>(); foreach (HtmlNode node in nodes_all) { if (node.CLASS() == "MatchContainer") { if (!node.InnerHtml.Contains("LiveMatchCompetitors")) { try { string date = node.SELECT_NODE("/div[1]/span[1]/strong[1]").ChildNodes[0].InnerText.E_TRIM(); string time = node.SELECT_NODE("/div[1]/span[1]/em[1]").ChildNodes[0].InnerText.E_TRIM(); string start_time = ""; if (date.E_TRIM().ToLower() != "live") { string[] dates = date.E_SPLIT("/"); date = dates[1] + "/" + dates[0]; start_time = date + M.D + time; } else { start_time = DateTime.Now.ToString("MM/dd") + M.D + time; } string host = node.SELECT_NODE("/div[2]/h3[1]/a[1]/span[1]").ChildNodes[0].InnerText; string client = node.SELECT_NODE("/div[2]/h3[1]/a[1]/span[3]").ChildNodes[0].InnerText; string odd_host = node.SELECT_NODE("div[4]/ol[1]/li[1]/a[1]/span[1]").InnerText; string odd_draw = node.SELECT_NODE("div[4]/ol[1]/li[2]/a[1]/span[1]").InnerText; string odd_away = node.SELECT_NODE("div[4]/ol[1]/li[3]/a[1]/span[1]").InnerText; BsonDocument doc_odd = AnalyseTool.get_odd_doc_from_europe(odd_host, odd_draw, odd_away); sb.Append(start_time.PR(20) + host.PR(30) + client.PR(30) + odd_host.PR(10) + odd_draw.PR(10) + odd_away.PR(10) + doc_odd["persent_return"].ToString() + M.N); Match100Helper.insert_data("betadonis", "", start_time, host, client, odd_host, odd_draw, odd_away, "2", "0"); } catch (Exception error) { } } } } return(sb.ToString()); }
public void read_500_team_detail() { //all info,include match info StringBuilder sb = new StringBuilder(); WebClient client = new WebClient(); string html = System.Text.Encoding.GetEncoding("GBK").GetString(client.DownloadData(root_url + "step3.htm")); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); string root = @"/html[1]/body[1]/div[3]/div[5]/div[1]/div[3]/ul[1]/li"; HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(root); sb.AppendLine("----"); foreach (HtmlNode node in nodes_all) { string xpath = node.XPath + "/a[1]"; HtmlNode final = doc.DocumentNode.SelectNodes(xpath)[0]; string text = final.InnerText; text = text.Replace('(', '●').Replace(')', ' '); string[] items = text.Split(new string[] { "●" }, StringSplitOptions.RemoveEmptyEntries); if (items.Length > 1) { sb.AppendLine(items[0].PR(100) + items[1].PR(100)); } } string root_matchs = @"/html[1]/body[1]/div[3]/div[6]/table[1]/tr[position()>1]"; HtmlNodeCollection nodes_match = doc.DocumentNode.SelectNodes(root_matchs); foreach (HtmlNode node in nodes_match) { HtmlNode node_leage = doc.DocumentNode.SelectNodes(node.XPath + "/td[1]/a[1]")[0]; HtmlNode node_time = doc.DocumentNode.SelectNodes(node.XPath + "/td[2]")[0]; HtmlNode node_host = doc.DocumentNode.SelectNodes(node.XPath + "/td[3]/a[1]")[0]; HtmlNode node_client = doc.DocumentNode.SelectNodes(node.XPath + "/td[5]/a[1]")[0]; Match100Helper.insert_future_match(node_leage.InnerText, node_time.InnerText, node_host.InnerText, node_client.InnerText); sb.AppendLine(node_leage.InnerText.PR(20) + node_time.InnerText.PR(30) + node_host.InnerText.PR(20) + node_client.InnerText.PR(20)); } this.txt_result.Text = sb.ToString(); Application.DoEvents(); }
public void get_single_by_start_time_desc(List <BsonDocument> list) { StringBuilder sb = new StringBuilder(); sb.Append("BY START TIME ASC:" + Environment.NewLine); DataTable dt = new DataTable(); DataColumn order = new DataColumn("order"); order.DataType = Type.GetType("System.Int32"); dt.Columns.Add(order); DataColumn persent = new DataColumn("start_time"); persent.DataType = Type.GetType("System.String"); dt.Columns.Add(persent); for (int i = 0; i < list.Count; i++) { DataRow row_new = dt.NewRow(); row_new["order"] = i; row_new["start_time"] = list[i]["start_time"].ToString(); dt.Rows.Add(row_new); } dt.DefaultView.Sort = "start_time desc"; dt = dt.DefaultView.ToTable(); foreach (DataRow row in dt.Rows) { BsonDocument doc = list[Convert.ToInt32(row["order"].ToString())]; sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); sb.Append(Match100Analyse2.get_info_from_doc(doc)); } sb.Append("----------------------------------------------------------------------------------------------------------------------------------------" + Environment.NewLine); this.txt_result.Text = sb.ToString(); Match100Helper.create_log_result(sb.ToString()); Application.DoEvents(); }
public void pick_from_single() { is_picking = true; //f_state: 0-未处理 1-已处理,值更新了时间 2-已处理,一个匹配 3-已处理,2个匹配 string id_min = "9999999999999999"; string sql = "select min(id) from europe_100_log where f_state='0' "; DataTable dt_min = SQLServerHelper.get_table(sql); if (!string.IsNullOrEmpty(dt_min.Rows[0][0].ToString())) { id_min = dt_min.Rows[0][0].ToString(); } sql = "select * from europe_100_log where f_state='0' "; DataTable dt = SQLServerHelper.get_table(sql); foreach (DataRow row in dt.Rows) { string id = row["id"].ToString(); string website = row["website"].ToString(); string start_time = row["start_time"].ToString(); string host = row["host"].ToString(); string client = row["client"].ToString(); string win = row["odd_win"].ToString(); string draw = row["odd_draw"].ToString(); string lose = row["odd_lose"].ToString(); string time_zone = row["time_zone"].ToString(); string time_add = row["time_add"].ToString(); string timespan = row["timespan"].ToString(); string convert_host = ""; string convert_client = ""; string convert_time = ""; string f_state = "1"; //try //{ convert_host = Match100Helper.convert_team_name(host); convert_client = Match100Helper.convert_team_name(client); DateTime time = Convert.ToDateTime(start_time).AddHours(8 - Convert.ToInt16(time_zone)); if (website == "pinnaclesports" && time.Minute % 5 != 0) { time = time.AddMinutes(Convert.ToInt16(time_add)); } convert_time = time.ToString("yyyy-MM-dd HH:mm:ss"); if (!string.IsNullOrEmpty(convert_host) || !string.IsNullOrEmpty(convert_client)) { f_state = "2"; } if (!string.IsNullOrEmpty(convert_host) && !string.IsNullOrEmpty(convert_client)) { f_state = "3"; } sql = " update europe_100_log set f_host='{0}',f_client='{1}',f_start_time='{2}' ,f_state='{3}' where id='{4}'"; sql = string.Format(sql, convert_host, convert_client, convert_time, f_state, id); SQLServerHelper.exe_sql(sql); sb.AppendLine(website.PR(10) + convert_time.PR(30) + convert_host.PR(50) + convert_client.PR(50)); this.txt_result.Text = sb.PR200(); Application.DoEvents(); //} //catch (Exception error) //{ // sql = " update europe_100_log set f_state='w' where id='{0}'"; // sql = string.Format(sql, id); // SQLServerHelper.exe_sql(sql); // sb.AppendLine(id + " Wrong!"); // this.txt_result.Text = sb.PRINT(); // Application.DoEvents(); //} } insert_office(); is_picking = false; }
public string insert_event_data(string input) { StringBuilder sb = new StringBuilder(); BsonDocument doc = MongoHelper.get_doc_from_str(input); BsonArray es = doc["events"].AsBsonArray; foreach (BsonDocument e in es) { try { string event_id = e["id"].ToString(); string start_time = e["start"].ToString(); string[] teams = e["name"].ToString().E_SPLIT(" vs "); string home = teams[0]; string away = teams[1]; string home_odd = ""; string draw_odd = ""; string away_odd = ""; BsonArray tags = e["meta-tags"].AsBsonArray; string country = ""; string competition = ""; for (int i = 0; i < tags.Count; i++) { if (tags[i]["type"].ToString() == "COUNTRY") { country = tags[i]["name"].ToString(); } if (tags[i]["type"].ToString() == "COMPETITION") { competition = tags[i]["name"].ToString(); } } string league = country + " " + competition; sb.Append(league.PR(30) + start_time.PR(30) + home.PR(30) + away.PR(30) + M.N); MbookSQL.insert_events(event_id, "Soccer", country, competition, start_time, home, away); BsonArray markets = e["markets"].AsBsonArray; foreach (BsonDocument market in markets) { string markert_name = market["name"].ToString(); BsonArray runners = market["runners"].AsBsonArray; foreach (BsonDocument runner in runners) { string runner_name = runner["name"].ToString(); BsonArray prices = runner["prices"].AsBsonArray; sb.Append(markert_name.PR(20) + runner_name.PR(20)); foreach (BsonDocument price in prices) { string side = price["side"].ToString(); string odd = price["odds"].ToString(); string amount = price["available-amount"].ToString(); sb.Append(side.ToUpper().PR(10) + odd.PR(10) + amount.PR(20)); MbookSQL.insert_market(event_id, markert_name, runner_name, "1", side, odd, amount); if (markert_name.Contains("Match Odds") & runner_name.Contains(home) & side == "back") { home_odd = odd; } if (markert_name.Contains("Match Odds") & runner_name.ToUpper().Contains("DRAW") & side == "back") { draw_odd = odd; } if (markert_name.Contains("Match Odds") & runner_name.Contains(away) & side == "back") { away_odd = odd; } } sb.Append(M.N); } DateTime dt_start_time = Convert.ToDateTime(start_time); if (markert_name.Contains("Match Odds")) { Match100Helper.insert_data("matchbook", country + "." + competition + "." + league, dt_start_time.ToString("yyyy-MM-dd HH:mm:ss"), home, away, home_odd, draw_odd, away_odd, "0", "0"); } } } catch (Exception error) { } } return(sb.ToString()); }
public string get_js_json(string str) { string result = str; int add = 0; for (int i = 1; i < str.Length; i++) { int num_len = 0; if (i + 1 < str.Length && Match100Helper.is_double_str(str.Substring(i, 1))) { num_len = 1; } if (i + 2 < str.Length && Match100Helper.is_double_str(str.Substring(i, 2))) { num_len = 2; } if (i + 3 < str.Length && Match100Helper.is_double_str(str.Substring(i, 3))) { num_len = 3; } if (i + 4 < str.Length && Match100Helper.is_double_str(str.Substring(i, 4))) { num_len = 4; } if (i + 5 < str.Length && Match100Helper.is_double_str(str.Substring(i, 5))) { num_len = 5; } if (i + 6 < str.Length && Match100Helper.is_double_str(str.Substring(i, 6))) { num_len = 6; } if (i + 7 < str.Length && Match100Helper.is_double_str(str.Substring(i, 7))) { num_len = 7; } if (i + 8 < str.Length && Match100Helper.is_double_str(str.Substring(i, 8))) { num_len = 8; } if (i + 9 < str.Length && Match100Helper.is_double_str(str.Substring(i, 9))) { num_len = 9; } if (i + 10 < str.Length && Match100Helper.is_double_str(str.Substring(i, 10))) { num_len = 10; } if ((i - 1 >= 0) && str.Substring(i - 1, 1) != "{" && str.Substring(i - 1, 1) != "[" && str.Substring(i - 1, 1) != "," && str.Substring(i - 1, 1) != ":") { continue; } if (i + num_len < str.Length && str.Substring(i + num_len, 1) != "}" && str.Substring(i + num_len, 1) != "]" && str.Substring(i + num_len, 1) != "," && str.Substring(i + num_len, 1) != ":") { continue; } if (num_len != 0) { result = result.Insert(i + add, "'"); result = result.Insert(i + num_len + 1 + add, "'"); add = add + 2; i = i + num_len; } } return(result); }
public string from_marathonbet(string html) { StringBuilder sb = new StringBuilder(); //------------------------------------------- html = html.Replace("<thead=\"\"", ""); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); List <HtmlNode> nodes = new List <HtmlNode>(); ArrayList list_lg = new ArrayList(); string league = ""; string start_time = ""; string host = ""; string client = ""; string win = ""; string draw = ""; string lose = ""; string date = ""; string time = ""; string zone = ""; foreach (HtmlNode node in nodes_all) { zone = "8"; if (node.Id == "timer") { //02.09.14, 14:47 (GMT+1) string timer = node.InnerText.E_TRIM(); DateTime dt_timer = new DateTime(Convert.ToInt16("20" + timer.Substring(6, 2)), Convert.ToInt16(timer.Substring(3, 2)), Convert.ToInt16(timer.Substring(0, 2)), Convert.ToInt16(timer.Substring(9, 2)), Convert.ToInt16(timer.Substring(12, 2)), 0); TimeSpan span = DateTime.Now - dt_timer; zone = (8 - Math.Round(span.TotalHours)).ToString(); } if (node.Id == "container_EVENTS") { HtmlNodeCollection nodes_div = node.SELECT_NODES("/div"); foreach (HtmlNode node_div in nodes_div) { if (node_div.Id.Contains("container")) { league = node_div.SELECT_NODE("div[1]/h2[1]").InnerText; HtmlNode test = node_div.SELECT_NODE("div[2]/div[1]/table[1]"); HtmlNodeCollection nodes_table = node_div.SELECT_NODES("div[2]/div[1]/table[1]/tbody"); foreach (HtmlNode node_table in nodes_table) { if (node_table.Id.Contains("event")) { date = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[2]").InnerText.E_TRIM(); date = date.Replace("2015", ""); if (date.Length == 10) { start_time = Tool.get_12m_from_eng(date.Substring(2, 3)) + "-" + date.Substring(0, 2) + "●" + date.Substring(5, 5); } if (date.Length == 5) { start_time = date; } host = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/span[1]/div[1]").InnerText; client = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tbody[1]/tr[1]/td[1]/span[1]/div[2]").InnerText; win = node_table.SELECT_NODE("/tr[1]/td[2]").InnerText.E_REMOVE(); draw = node_table.SELECT_NODE("/tr[1]/td[3]").InnerText.E_REMOVE(); lose = node_table.SELECT_NODE("/tr[1]/td[4]").InnerText.E_REMOVE(); if (win.Contains("/")) { win = AnalyseTool.convert_english_odd(win); draw = AnalyseTool.convert_english_odd(draw); lose = AnalyseTool.convert_english_odd(lose); } if (!string.IsNullOrEmpty(win.E_TRIM()) && !string.IsNullOrEmpty(draw.E_TRIM()) && !string.IsNullOrEmpty(lose.E_TRIM())) { sb.AppendLine(league.PR(50) + start_time.PR(20) + host.PR(30) + client.PR(30) + win.PR(10) + draw.PR(10) + lose.PR(10)); Match100Helper.insert_data("marathonbet", league, start_time, host, client, win, draw, lose, "0", zone); } } } } } } } //------------------------------------------------------ return(sb.ToString()); }
private void btn_90vs_read_all_team_Click(object sender, EventArgs e) { string path = root_path_90vs + "leages_url.txt"; sb.Remove(0, sb.Length); FileStream stream = (FileStream)File.Open(path, FileMode.Open); StreamReader reader = new StreamReader(stream); string url = ""; while (url != null) { url = reader.ReadLine(); try { WebClient client = new WebClient(); string html = System.Text.Encoding.UTF8.GetString(client.DownloadData(url)); string[] list_line = html.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); BsonDocument doc_teams = new BsonDocument(); BsonDocument doc_lg = new BsonDocument(); foreach (string line in list_line) { if (line != null) { string[] items = line.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries); if (items.Length == 2) { string name = items[0].Replace("var", "").Trim(); string value = items[1].Replace(";", ""); if (name == "all_player_str") { doc_teams = MongoHelper.get_doc_from_str(get_js_json(value)); } if (name == "this_match") { doc_lg = MongoHelper.get_doc_from_str(get_js_json(value)); } } } } string lg_id = doc_lg["1"].AsBsonArray[0].ToString(); string lg_name_full = doc_lg["1"].AsBsonArray[1].ToString(); string lg_name = doc_lg["1"].AsBsonArray[2].ToString(); string lg_season_name = doc_lg["1"].AsBsonArray[5].ToString(); foreach (BsonElement element in doc_teams.Elements) { if (element.Name == "1") { continue; } string team_name_eng = ""; string team_name_chi = ""; string team_name_gd = ""; team_name_eng = element.Value.AsBsonArray[2].ToString(); team_name_chi = element.Value.AsBsonArray[1].ToString(); team_name_gd = element.Value.AsBsonArray[0].ToString(); Match100Helper.insert_teams_log("90vs", lg_season_name, "", lg_name, lg_name_full, team_name_eng, team_name_chi, team_name_gd); } sb.AppendLine(url); this.txt_result.Text = sb.ToString(); Application.DoEvents(); } catch (Exception error) { sb.AppendLine("----------------" + url); this.txt_result.Text = sb.ToString(); Application.DoEvents(); } } reader.Close(); stream.Close(); }
public BsonDocument from_pinnaclesports_me(ref WebBrowser browser, BsonDocument doc_result) { string html = BrowserHelper.get_html(ref browser); StringBuilder sb = new StringBuilder(); string result = ""; string url = ""; try { //================================================================ if (doc_result["url2"].AsBsonArray.Count == 0) { url = doc_result["url1"].AsBsonArray[0].ToString(); doc_result["url2"].AsBsonArray.Add(url); browser.Navigate(url); doc_result["loop"].AsBsonArray.Add("2"); doc_result["data"] = "Start Read First URL ->" + url; doc_result["url"] = browser.Document.Url.ToString(); return(doc_result); } //--------------------------------------------------------------- HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); ArrayList list_lg = new ArrayList(); ArrayList list_times = new ArrayList(); ArrayList list_teams = new ArrayList(); ArrayList list_odds = new ArrayList(); foreach (HtmlNode node in nodes_all) { if (node.Name == "table" && node.Attributes.Contains("class") && node.Attributes["class"].Value == "linesTbl") { if (doc.DocumentNode.SelectSingleNode(node.XPath + "/tbody[1]/tr[2]/td[1]").InnerText.ToLower().Contains("half")) { continue; } string lg_name = ""; string tr_path = node.XPath + "/tbody[1]/tr"; HtmlNodeCollection nodes_tr = doc.DocumentNode.SelectNodes(tr_path); foreach (HtmlNode node_tr in nodes_tr) { switch (node_tr.Attributes["class"].Value.ToString()) { case "linesHeader": string lg_temp = doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[1]/h4[1]").InnerText; string[] lg_list = lg_temp.Split('-'); lg_name = lg_list[0] + "-" + lg_list[1]; break; case "linesAlt1": if (string.IsNullOrEmpty(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Replace(" ", "").Trim())) { continue; } if (doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Contains("Offline")) { continue; } list_lg.Add(lg_name); list_times.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[1]").InnerText); list_teams.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[3]").InnerText); list_odds.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Replace(" ", "").Trim()); break; case "linesAlt2": if (string.IsNullOrEmpty(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Replace(" ", "").Trim())) { continue; } if (doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Contains("Offline")) { continue; } list_lg.Add(lg_name); list_times.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[1]").InnerText); list_teams.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[3]").InnerText); list_odds.Add(doc.DocumentNode.SelectSingleNode(node_tr.XPath + "/td[6]").InnerText.Replace(" ", "").Trim()); break; default: break; } } } } for (int i = 0; i < list_lg.Count; i++) { if ((i + 2) < list_lg.Count) { string f_lg = list_lg[i].ToString(); string f_time = list_times[i].ToString() + " " + list_times[i + 1].ToString(); string f_host = list_teams[i].ToString(); string f_client = list_teams[i + 1].ToString(); string f_win = list_odds[i].ToString(); string f_draw = list_odds[i + 2].ToString(); string f_lose = list_odds[i + 1].ToString(); Match100Helper.insert_data("pinnaclesports", f_lg, f_time, f_host, f_client, f_win, f_draw, f_lose, "-7", "1"); sb.AppendLine(f_lg.PR(50) + f_time.PR(20) + f_host.PR(30) + f_client.PR(30) + f_win.PR(20) + f_draw.PR(20) + f_lose.PR(20)); } i = i + 2; } } catch (Exception error) { sb.AppendLine(error.Message + Environment.NewLine + error.StackTrace); Log.error("from_pinnaclesports_2", error); } //-------------------------------------------------------------- if (doc_result["url1"].AsBsonArray.Count == doc_result["url2"].AsBsonArray.Count) { doc_result["url"] = browser.Document.Url.ToString(); doc_result["data"] = result; doc_result["loop"].AsBsonArray.Clear(); return(doc_result); } url = doc_result["url1"].AsBsonArray[doc_result["url2"].AsBsonArray.Count].ToString(); doc_result["url2"].AsBsonArray.Add(url); browser.Navigate(url); doc_result["loop"].AsBsonArray.Clear(); doc_result["loop"].AsBsonArray.Add("2"); //=============================================================== doc_result["data"] = sb.ToString(); doc_result["url"] = browser.Document.Url.ToString(); return(doc_result); }
public string insert_event_data_new(string html) { StringBuilder sb = new StringBuilder(); html = html.Replace("<thead=\"\"", ""); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); HtmlNodeCollection nodes_all = doc.DocumentNode.SelectNodes(@"//*"); List <HtmlNode> nodes = new List <HtmlNode>(); ArrayList list_lg = new ArrayList(); string league = ""; DateTime dt_server = new DateTime(); string start_time = ""; string host = ""; string client = ""; string win = ""; string draw = ""; string lose = ""; string date = ""; string time = ""; string zone = ""; string event_id = ""; HtmlNode node_timer = doc.DocumentNode.SELECT_NODE("/html[1]/head[1]/script[2]"); BsonDocument doc_timer = MongoHelper.get_doc_from_str(node_timer.InnerText.Replace("//<![CDATA[", "").Replace("//]]>>", "").Replace("initData =", "")); string server_time = doc_timer["serverTime"].ToString().E_TRIM(); string zone_gmt = doc_timer["tzPrefix"].ToString().E_TRIM(); zone_gmt = zone_gmt.Replace("GMT", ""); zone = string.IsNullOrEmpty(zone_gmt) ? "0" : zone_gmt; string[] times = server_time.E_SPLIT(","); dt_server = new DateTime(Convert.ToInt16(times[0]), Convert.ToInt16(times[1]), Convert.ToInt16(times[2]), Convert.ToInt16(times[3]), Convert.ToInt16(times[4]), Convert.ToInt16(times[5])); //TimeSpan span = DateTime.Now - dt_server; //zone = (8 - Math.Round(span.TotalHours)).ToString(); foreach (HtmlNode node in nodes_all) { if (node.Id == "container_EVENTS") { HtmlNodeCollection nodes_div = node.SELECT_NODES("/div"); foreach (HtmlNode node_div in nodes_div) { if (node_div.Id.Contains("container")) { league = node_div.SELECT_NODE("div[1]/h2[1]").InnerText; HtmlNode test = node_div.SELECT_NODE("div[2]/div[1]/table[1]"); HtmlNodeCollection nodes_table = node_div.SELECT_NODES("div[2]/div[1]/table[1]/tbody"); foreach (HtmlNode node_table in nodes_table) { if (node_table.Id.Contains("event")) { event_id = node_table.Id.Replace("event_", ""); date = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tr[1]/td[2]").InnerText.E_TRIM(); date = date.Replace("2015", ""); if (date.Length == 10) { start_time = dt_server.ToString("yyyy-") + Tool.get_12m_from_eng(date.Substring(2, 3)) + "-" + date.Substring(0, 2) + " " + date.Substring(5, 5); } if (date.Length == 5) { start_time = dt_server.ToString("yyyy-") + dt_server.ToString("MM-dd") + " " + date; } DateTime dt_time = Convert.ToDateTime(start_time); dt_time = dt_time.AddHours(Convert.ToInt16(zone) * (-1)); host = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tr[1]/td[1]/span[1]/div[1]").InnerText; client = node_table.SELECT_NODE("/tr[1]/td[1]/table[1]/tr[1]/td[1]/span[1]/div[2]").InnerText; win = node_table.SELECT_NODE("/tr[1]/td[2]").InnerText.E_REMOVE(); draw = node_table.SELECT_NODE("/tr[1]/td[3]").InnerText.E_REMOVE(); lose = node_table.SELECT_NODE("/tr[1]/td[4]").InnerText.E_REMOVE(); if (win.Contains("/")) { win = AnalyseTool.convert_english_odd(win); draw = AnalyseTool.convert_english_odd(draw); lose = AnalyseTool.convert_english_odd(lose); } if (!string.IsNullOrEmpty(win.E_TRIM()) && !string.IsNullOrEmpty(draw.E_TRIM()) && !string.IsNullOrEmpty(lose.E_TRIM())) { sb.AppendLine(event_id.PR(10) + league.PR(50) + dt_time.ToString("yyyy-MM-dd HH:mm:ss").PR(20) + host.PR(30) + client.PR(30) + win.PR(10) + draw.PR(10) + lose.PR(10)); Match100Helper.insert_data("marathonbet", league, start_time, host, client, win, draw, lose, "0", zone); MbSQL.insert_events(event_id, league.E_TRIM(), dt_time.ToString("yyyy-MM-dd HH:mm:ss"), host, client); ; } } } } } } } return(sb.ToString()); }