protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //GridView1.DataSource = bll.GetScrollMatchList(); //GridView1.DataBind(); WebClient web = WebClientBLL.getWebClient(); string s = web.DownloadString("http://data.nowscore.com/detail/403052.html"); Lexer lexer = new Lexer(s); Parser parser = new Parser(lexer); INode tableNode = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children[0]; TableTag tt = tableNode as TableTag; Response.Write(tt.GetRow(0).Columns[0].Children[0].Children[0].ToPlainTextString()); Response.Write(tt.GetRow(0).Columns[1].Children[0].Children[0].ToPlainTextString()); Response.Write(tt.GetRow(0).Columns[2].Children[0].Children[0].ToPlainTextString()); //ITag divNode = bodyNodes.ExtractAllNodesThatMatch(new TagNameFilter("FORM"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("DIV"))[0] as ITag; //if (divNode.Attributes["ID"].Equals("PageBody")) //{ // NodeList dataDivList = divNode.Children.SearchFor(typeof(Winista.Text.HtmlParser.Tags.Div)); //} } }
private string getMatchResult(string matchid) { WebClientBLL bll = new WebClientBLL(); string html = bll.GetRemoteHtml("/detail/{0}.html", new string[] { matchid }); Lexer lexer = new Lexer(html); Parser parser = new Parser(lexer); INode tableNode = parser.Parse(new TagNameFilter("HTML"))[0].Children.ExtractAllNodesThatMatch(new TagNameFilter("BODY"))[0].Children[0]; TableTag tt = tableNode as TableTag; string home = tt.GetRow(0).Columns[0].Children[0].Children[0].ToPlainTextString(); string away = tt.GetRow(0).Columns[2].Children[0].Children[0].ToPlainTextString(); string hscore = tt.GetRow(0).Columns[1].Children[0].Children[1].Children[0].ToPlainTextString(); string ascore = tt.GetRow(0).Columns[1].Children[0].Children[1].Children[2].ToPlainTextString(); string asia = tt.GetRow(0).Columns[1].Children[0].Children[0].Children[0].ToPlainTextString(); return(home + " " + hscore + "-" + ascore + " " + away + " " + asia); }