Visual Basic and Html Agility Pack

nodyguy

Supreme Member
Joined
Feb 8, 2012
Messages
1,344
Reaction score
544
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!
 
bump - 15 characters limit
 
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.
 
Back
Top