1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Visual Basic and Html Agility Pack

Discussion in 'Visual Basic .NET' started by nodyguy, Nov 11, 2013.

  1. nodyguy

    nodyguy Jr. VIP Jr. VIP

    Joined:
    Feb 8, 2012
    Messages:
    369
    Likes Received:
    60
    Gender:
    Male
    Hey everyone, Im trying to get the values of top country in google.com/trends.
    My Example URL is: http://www.google.com/trends/explore?q=harta#q=harta
    and I want to get this: http://puu.sh/5fwSX.png

    My code:
    Code:
    Private Sub ButtonBlue2_Click(sender As Object, e As EventArgs) Handles ButtonBlue2.Click        
            
            Dim Web As New HtmlAgilityPack.HtmlWeb
            Dim Doc As New HtmlAgilityPack.HtmlDocument
            Dim htmlDoc = New HtmlAgilityPack.HtmlDocument()
    
    
            htmlDoc.LoadHtml("http://www.google.com/trends/explore?q=harta#q=harta&cmpt=q")
            For Each node In htmlDoc.DocumentNode.SelectNodes("//span[@class='trends-bar-chart-name']//a")
                MsgBox(node.InnerText.ToString())
            Next
    
    
        End Sub
    anyone have a clue what wrong with my code? Im getting object refer error.
    Thanks!
     
  2. nodyguy

    nodyguy Jr. VIP Jr. VIP

    Joined:
    Feb 8, 2012
    Messages:
    369
    Likes Received:
    60
    Gender:
    Male
    bump - 15 characters limit
     
  3. garthor

    garthor Newbie

    Joined:
    Mar 24, 2013
    Messages:
    48
    Likes Received:
    13
    Although this post is a bit old, I would try removing the //a from the selectnodes.
    Then, I would simply get the link using the Children property :)

    I'm not sure if that will do it, I'm not able to test this code as my country Google Trends is different.