public static TreeTableAndList get_tree_table_from_url(string url) { TreeTableAndList result = new TreeTableAndList(); WebClient client = new WebClient(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); string html = System.Text.Encoding.UTF8.GetString(client.DownloadData(url)); doc.LoadHtml(html); DataTable table = new DataTable(); for (int i = 0; i < 500; i++) { table.Columns.Add("C" + i.ToString()); } ArrayList list = new ArrayList(); for (int i = 0; i < 500; i++) { list.Add(new ArrayList()); } add_row_to_tree_table(-1, ref table, ref list, doc.DocumentNode); result.table = table; result.list = list; return(result); }
public static TreeTableAndList get_tree_table_from_local(string html) { TreeTableAndList result = new TreeTableAndList(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); DataTable table = new DataTable(); for (int i = 0; i < 500; i++) { table.Columns.Add("C" + i.ToString()); } ArrayList list = new ArrayList(); for (int i = 0; i < 500; i++) { list.Add(new ArrayList()); } add_row_to_tree_table(-1, ref table, ref list, doc.DocumentNode); result.table = table; result.list = list; return(result); }
private void btn_pick_to_table_Click(object sender, EventArgs e) { TreeTableAndList result = new TreeTableAndList(); if (cb_local.Checked) { result = AutoPickHelper.get_tree_table_from_local(this.txt_local.Text); } else { result = AutoPickHelper.get_tree_table_from_url(this.txt_url.Text); } this.dgv_tree.DataSource = result.table; StringBuilder sb = new StringBuilder(); for (int i = 0; i < result.list.Count; i++) { sb.Append(i.ToString() + "[" + ((ArrayList)result.list[i]).Count + "]: "); foreach (int item in (ArrayList)result.list[i]) { sb.Append(item.ToString() + " "); } sb.Append(Environment.NewLine); } this.txt_result.Text = sb.ToString(); DataTable dt_filter = new DataTable(); for (int i = 0; i < 500; i++) { dt_filter.Columns.Add("C" + i.ToString()); } StringBuilder filter_sb = new StringBuilder(); DataTable dt_table = result.table; for (int i = 0; i < dt_table.Rows.Count; i++) { for (int j = 0; j < dt_table.Columns.Count; j++) { string value = dt_table.Rows[i][j].ToString(); if (value.Length > 4 && value.Substring(0, 4) == "$$$$") { if (!value.Contains("<!--") && !value.Contains("{") && !value.Contains("|")) { DataRow row_new = dt_filter.NewRow(); row_new[j] = dt_table.Rows[i][j].ToString().Replace("$$$$", ""); filter_sb.Append(dt_table.Rows[i][j].ToString().Replace("$$$$", "") + Environment.NewLine); dt_filter.Rows.Add(row_new); } } } } this.dgv_filter.DataSource = dt_filter; this.txt_filter.Text = filter_sb.ToString(); }
private void btn_pick_to_table_Click(object sender, EventArgs e) { TreeTableAndList result = new TreeTableAndList(); if (cb_local.Checked) { result = AutoPickHelper.get_tree_table_from_local(this.txt_local.Text); } else { result = AutoPickHelper.get_tree_table_from_url(this.txt_url.Text); } this.dgv_tree.DataSource = result.table; StringBuilder sb = new StringBuilder(); for (int i = 0; i < result.list.Count; i++) { sb.Append(i.ToString() + "["+((ArrayList)result.list[i]).Count +"]: "); foreach (int item in (ArrayList)result.list[i]) { sb.Append(item.ToString() + " "); } sb.Append(Environment.NewLine); } this.txt_result.Text = sb.ToString(); DataTable dt_filter = new DataTable(); for (int i = 0; i < 500; i++) { dt_filter.Columns.Add("C" + i.ToString()); } StringBuilder filter_sb = new StringBuilder(); DataTable dt_table = result.table; for (int i = 0; i < dt_table.Rows.Count; i++) { for(int j=0;j<dt_table.Columns.Count;j++) { string value = dt_table.Rows[i][j].ToString(); if (value.Length > 4 && value.Substring(0, 4) == "$$$$") { if (!value.Contains("<!--") && !value.Contains("{") && !value.Contains("|")) { DataRow row_new = dt_filter.NewRow(); row_new[j] = dt_table.Rows[i][j].ToString().Replace("$$$$", ""); filter_sb.Append(dt_table.Rows[i][j].ToString().Replace("$$$$", "") + Environment.NewLine); dt_filter.Rows.Add(row_new); } } } } this.dgv_filter.DataSource = dt_filter; this.txt_filter.Text = filter_sb.ToString(); }
public static TreeTableAndList get_tree_table_from_url(string url) { TreeTableAndList result = new TreeTableAndList(); WebClient client = new WebClient(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); string html = System.Text.Encoding.UTF8.GetString(client.DownloadData(url)); doc.LoadHtml(html); DataTable table = new DataTable(); for (int i = 0; i < 500; i++) { table.Columns.Add("C" + i.ToString()); } ArrayList list = new ArrayList(); for (int i = 0; i < 500; i++) { list.Add(new ArrayList()); } add_row_to_tree_table(-1, ref table,ref list, doc.DocumentNode); result.table = table; result.list = list; return result; }
public static TreeTableAndList get_tree_table_from_local(string html) { TreeTableAndList result = new TreeTableAndList(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(html); DataTable table = new DataTable(); for (int i = 0; i < 500; i++) { table.Columns.Add("C" + i.ToString()); } ArrayList list = new ArrayList(); for (int i = 0; i < 500; i++) { list.Add(new ArrayList()); } add_row_to_tree_table(-1, ref table,ref list, doc.DocumentNode); result.table = table; result.list = list; return result; }