03
May
09

[VB.Net] The beginnings of a Neopets bot

Ive decided that I’ve had enough of javascript, and so im going to move to VB.net to attempt to create a better bot. The auction bot itself, is, very good. However, now I want an autobuyer, and I cant get that to work in javascript as firefox doesn’t want to display the image when haggling..

Ive decided to do it using a webbrowser control, for ease of accessing the elements on the page, and below is a quick example of logging into neopets.

    Private Enum Bot_State
        Initial
        LogIn
        LoggingIn1
        LoggingIn2
        LoggingIn3
        LoggedIn
    End Enum

    Dim State As Bot_State = Bot_State.Initial
    Dim Username As String = "username"
    Dim Password As String = "password"

    ''web = System.Windows.Forms.WebBrowser
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        web.Navigate("http://neopets.com")
    End Sub

    Private Sub web_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles web.DocumentCompleted
        Select Case State
            Case Bot_State.Initial
                If web.Document.Body.InnerHtml.IndexOf("Login") <> -1 Then
                    State = Bot_State.LogIn
                    web.Navigate(web.Url.AbsoluteUri & "/loginpage.phtml")
                Else
                    State = Bot_State.LoggedIn
                End If
            Case Bot_State.LogIn
                Dim UserTB As HtmlElement = web.Document.GetElementById("txtUsername")
                UserTB.SetAttribute("value", Username)
                UserTB.Parent().Parent().Parent().Parent().DomElement.Submit()
                State = Bot_State.LoggingIn1
            Case Bot_State.LoggingIn1
                State = Bot_State.LoggingIn2
            Case Bot_State.LoggingIn2
                Dim PageInput As HtmlElementCollection = web.Document.GetElementsByTagName("input")
                For Each elem As HtmlElement In PageInput
                    If elem.GetAttribute("name") = "password" Then
                        elem.SetAttribute("value", Password)
                        elem.Parent().Parent().Parent().Parent().DomElement.Submit()
                    End If
                Next
                State = Bot_State.LoggingIn3
            Case Bot_State.LoggingIn3
                If web.Url.AbsoluteUri.IndexOf("index") Then
                    State = Bot_State.LoggedIn
                Else
                    State = Bot_State.LogIn
                    web.Navigate(web.Url.AbsoluteUri & "/loginpage.phtml")
                End If
        End Select
    End Sub
Advertisements

1 Response to “[VB.Net] The beginnings of a Neopets bot”


  1. November 23, 2009 at 11:08 pm

    I think I am going to use this code as a starter and try to make an auto login script for other websites 😛


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: