Oppure

Loading
10/06/11 16:02
federiko
ciao ragazzi vorrei sapere come creare un programma x il login automatico sul sito megaupload.com.. fino ad ora ho creato una pezzo di codice ma mi da errore errore a questa riga:"but1 = WebBrowser1.Document.GetElementById("a href=javascript:void(0)";).DomElement" :(


Public Class Form1

    Dim whereami As Integer
    Dim loggedin As Boolean

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        whereami = 0
        loggedin = False
        WebBrowser1.Navigate("http://www.megaupload.com/?c=login")
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        If whereami = 0 Then
            Dim but1 As Object
            WebBrowser1.Document.GetElementById("username").SetAttribute("value", "username1")
            WebBrowser1.Document.GetElementById("password").SetAttribute("value", "1234567")
            but1 = WebBrowser1.Document.GetElementById("a href=javascript:void(0)").DomElement
            but1.Click()
            whereami = whereami + 1
            Exit Sub
        ElseIf whereami = 1 Then
            WebBrowser1.Navigate("http://www.megaupload.com/?c=login")
            whereami = whereami + 1
            Exit Sub
        ElseIf whereami = 2 Then
            Dim dom As Object
            dom = WebBrowser1.Document.DomDocument
            dom.Links(1).Click()
            whereami = whereami + 1
            loggedin = True
            Exit Sub
        End If
    End Sub

    Sub placebets(ByVal batchbets As String)
        Dim olddate As Date
        Dim procs() As Process
        WebBrowser1.Document.GetElementById("BvTextArea").InnerText = batchbets
        ClickLink(WebBrowser1.Document.DomDocument, "SUBMIT BATCH")
        olddate = Now
        'Wait five seconds until the confirmation window opens
        Do
            Application.DoEvents()
        Loop Until DateDiff(DateInterval.Second, olddate, Now) >= 5 Or DateDiff(DateInterval.Second, olddate, Now) <= -5
        procs = Process.GetProcesses()
        'close confirmation window
        For i = 0 To procs.Length - 1
            If procs(i).MainWindowTitle = "https://www.tab.com.au/?State=1 - BetReceiptSummary - Windows Internet Explorer" Then
                procs(i).CloseMainWindow()
                Exit For
            End If
        Next
    End Sub

    Sub ClickLink(ByVal doc As Object, ByVal LinkText As String)
        For i = 0 To doc.Links.Length - 1
            If LTrim(RTrim(doc.Links(i).OuterText)) = LinkText Then
                doc.Links(i).Click()
                Exit For
            End If
        Next i
    End Sub
End Class



:(:(
aaa
10/06/11 16:41
walker93
semplicemente perchè "a href=javascript:void(0)" non è l'id che dovresti inserire nella funzione "GetElementById()"

l'hai usata benissimo per username e password, allo stesso modo devi usarla per
il bottone login.
ho guardato il codice sorgente e il bottone non ha ne un ID ne un nome:
<a href="javascript:void(0);" onclick="postlogin();" class="log_but1">Login</a>


Però c'è lo ha il form che contiene i campi e il bottone, ed è : loginfrm
quindi sostituisci "a href=javascript:void(0)" con "loginfrm" e usa .submit() al posto di .click()
dovrebbe funzionare, nel caso chiedi...
aaa
10/06/11 17:04
federiko
grande Walker93!!!! :love::love:

bè nn è ke ora potresti risolvere un altro mio problema XD.. dunque mi connetto al sito del download e voglio scaricare un file e l'unico modo è "cliccare" un bottone.. come posso far fare tutto questo in automatico a VB???
aaa
10/06/11 20:50
walker93
esattamente come hai fatto fino ad adesso:
se il bottone ha un Id o un nome usi:
bottone = WebBrowser1.Document.GetElementById("id bottone").DomElement
bottone.click()

altrimenti cerchi il form in cui è contenuto e usi l'id di quello ma con .submit() al posto di .click()
aaa
11/06/11 15:41
federiko
in questo caso c'è lo stesso problema di prima.. neanche qui c'è un id o nome al bottone ma nn c'è neanche un form principale :(

guarda il codice esempio della pagina dove c'è il bottone:

<div class="down_butt_pad1" style="" id="downloadlink"><a href="example.it"; class="down_butt1"></a></div>


io ho fatto questo codice:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim bottone As Object
        bottone = WebBrowser1.Document.GetElementById("down_butt_pad1").DomElement
        bottone.click()
    End Sub


xò mi da questo errore"Riferimento a un oggetto non impostato su un'istanza di oggetto."

please help me!! :(
aaa