none
VB2010怎么实现自动填表啊 RRS feed

  • 问题

  • 各位高手,问一个问题。VB2010怎么实现论坛自动登录,比如用登录百度贴吧自动发帖。怎么实现
    Vb2010怎么制作发帖机
    2011年12月17日 4:55

答案

  • 你好,我这有个自动登录的例子,你可以试试:

        Private Sub AutoLogin_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.WebBrowser1.Navigate("E:\Projects\WinApp-webbrowser\WinApp-webbrowser\Loginform.htm")
            'Me.WebBrowser1.Navigate("www.google.com.hk")
        End Sub
    
        'Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        '    Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        '    For Each curElement As HtmlElement In theElementCollection
        '        Dim controlName As String = curElement.GetAttribute("id").ToString
        '        If controlName = "usernameLogin" Then
        '            curElement.SetAttribute("Value", "username")
        '        ElseIf controlName = "passwordLogin" Then
        '            curElement.SetAttribute("Value", "password")
        '        End If
        '    Next
        'End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
                Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("form")
                For Each curElement As HtmlElement In theElementCollection
                    If curElement.GetAttribute("action") = "http:\\www.google.com.hk" Then curElement.InvokeMember("submit")
                Next
            End If
        End Sub
    

    这段代码中的注释部分也很有参考价值的,别忽略了。

    另外你需要做些调整,然后才能跟你自己原本的程序融合。


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    2011年12月19日 4:01
    版主

全部回复

  • 你好,我这有个自动登录的例子,你可以试试:

        Private Sub AutoLogin_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Me.WebBrowser1.Navigate("E:\Projects\WinApp-webbrowser\WinApp-webbrowser\Loginform.htm")
            'Me.WebBrowser1.Navigate("www.google.com.hk")
        End Sub
    
        'Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        '    Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input")
        '    For Each curElement As HtmlElement In theElementCollection
        '        Dim controlName As String = curElement.GetAttribute("id").ToString
        '        If controlName = "usernameLogin" Then
        '            curElement.SetAttribute("Value", "username")
        '        ElseIf controlName = "passwordLogin" Then
        '            curElement.SetAttribute("Value", "password")
        '        End If
        '    Next
        'End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
                Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("form")
                For Each curElement As HtmlElement In theElementCollection
                    If curElement.GetAttribute("action") = "http:\\www.google.com.hk" Then curElement.InvokeMember("submit")
                Next
            End If
        End Sub
    

    这段代码中的注释部分也很有参考价值的,别忽略了。

    另外你需要做些调整,然后才能跟你自己原本的程序融合。


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    2011年12月19日 4:01
    版主
  • 谢谢朋友了,我去试一试

    2011年12月23日 11:16