1

I am trying to extract a table from a webpage using Html Agility Pack. So far I have managed to do a little of progress with it. This is my code so far

    Dim web As New HtmlAgilityPack.HtmlWeb()
    Dim htmlDoc As HtmlAgilityPack.HtmlDocument = web.Load("--Website url--")
    Dim html As String = htmlDoc.DocumentNode.OuterHtml

    Dim tabletag = htmlDoc.DocumentNode.SelectNodes("//table")

Basically I need to find a table with the following html tag

     <table width="100%"  border="0" cellspacing="0" cellpadding="3" summary="Contains search results">

Any Idea how I can strip down my search for tables to that specific table ?

4

1 に答える 1

2

ドキュメント内のすべてのテーブルの中で一意になるのは、テーブルについて何であるかを判断する必要があります。これは、テーブルを一意にする属性など、テーブルの属性の1つである可能性がありますsummary。または、検索する必要があるテーブル内の子要素の1つである可能性があります。指定しなかったので、summary属性に基づいて結果を制限する方法の例を示します。

Dim tabletag = htmlDoc.DocumentNode.SelectNodes("//table[@summary='Contains search results']")
于 2012-07-10T12:22:53.980 に答える