Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - http agility pack xpath
Forum - C# / VB.NET - http agility pack xpath

Avatar
omar89 (Normal User)
Newbie


Messaggi: 1
Iscritto: 30/04/2012

Segnala al moderatore
Postato alle 9:14
Lunedė, 30/04/2012
ciao a tutti volevo sapere se qualcuno poteva aiutarmi per capire come si utilizza httpagilitypack in relazione a questo esempio:
http code:
Codice sorgente - presumibilmente C# / VB.NET

  1. <TABLE id=uezszu_24 class="uiGrid fbPhotosGrid" cellSpacing=0 cellPadding=0>
  2.   <TBODY>
  3.   <TR>
  4.     <TD class="vTop">
  5.       <DIV class=Wrapper><A
  6.       class="uiMediaThumb uiScrollableThumb uiMediaThumbHuge"
  7.       href="www.cccc.com/index.php"
  8.       name=43563463 rel=theater aria-label="photo"
  9.       ajaxify="dsgdgbdfgr45y6ghd"><I
  10.       style="BACKGROUND-IMAGE: url(http://www.fressdgf.com/image.jpg)"></I></A></DIV></TD>
  11.       </TR>
  12.       </TBODY>
  13.       </TABLE>




io ho provato ad utilizzare come codice vb:
Codice sorgente - presumibilmente VB.NET

  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.        
  3.         Dim site As HtmlAgilityPack.HtmlWeb = New HtmlWeb()
  4.         Dim document As HtmlAgilityPack.HtmlDocument = site.Load("https://www.site.com")
  5.         For Each table As HtmlNode In document.DocumentNode.SelectNodes("//tr")
  6.  
  7.             ListBox1.Items.Add(table.InnerText)
  8.  
  9.         Next
  10.     End Sub


PM Quote
Avatar
francescobigozzi (Normal User)
Rookie


Messaggi: 30
Iscritto: 29/01/2010

Segnala al moderatore
Postato alle 22:11
Giovedė, 03/05/2012
Ciao,
in quell'esempio usi una funzione che ti restituisce tutte le righe di tutte le tabelle (tr) contenute nella  index di https://www.site.com.

Codice sorgente - presumibilmente C# / VB.NET

  1. HtmlDocument doc = new HtmlDocument();
  2. doc.LoadHtml("pippo.html");
  3. HtmlNodeCollection links = doc.DocumentNode.SelectNodes("//a[@href]");



Alalogamente questo esempio (in C#) restituisce tutti i link con attributo href contenuti nella pagina pippo.html.

Spero ti sia di aiuto! :)

PM Quote