Clicking A Website Button (HtmlElementCollection)

johnnyj2j

Member
Joined
Mar 4, 2013
Messages
13
Programming Experience
1-3
so im making a bot for the site youlikehits.com and im having some difficulty I can get it to press the first button the will load a the first page but I cant get it to load the next button on that page as show below the first pic is the starting page and the button (click 1) makes it go to the second page
11bn4pd.png

but then once on the second page its suppose to click view with the button (click 2) but I cant figure out how to get it to do that and it doesn't work
2ql8x3r.png

I think it might have something to do with the source code being different after I load page 2 any help is aprechiated thanks in advance
VB.NET:
Public Class Name
 
    Private Sub Name_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        WebBrowser1.Navigate("[URL="http://www.youlikehits.com/stats.php"]YouLikeHits - Free Twitter Followers, YouTube Views, YouTube Subscribers, Website Hits[/URL]")

    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

        For Each webpageelement As HtmlElement In allelements

            If webpageelement.GetAttribute("data") = "youtubenew.php" Then

                webpageelement.InvokeMember("click")

            End If

        Next

    End Sub
 
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

        For Each webpageelement As HtmlElement In allelements

            If webpageelement.GetAttribute("class") = "followbutton" Then

                webpageelement.InvokeMember("click")

            End If

        Next

    End Sub
 
    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

        TextBox1.Text = WebBrowser1.Url.ToString

    End Sub

End Class
 
Last edited:
Back
Top