0
我在嘗試創建一個工具來管理多個slideshare帳戶。手動登錄和註銷每一個都很麻煩,所以想到創建一個簡單的webbrowser工具來爲我做登錄。登錄到slideshare
問題是,當我嘗試點擊登錄按鈕時,它告訴我'需要填充的字段'(並且它們是)然後當我關注控件並嘗試手動按下登錄(從web瀏覽器控件)我告訴我,這是'無效的用戶名/密碼組合'
我甚至更進了一步,並從輸入中刪除了文本,並從文本文件中重排了相同的文件,但同一個'無效的用戶/密碼'按摩出現。
當我嘗試喲從實際的IE瀏覽器手動執行此操作時,它登錄沒有問題。我不知道我在做什麼錯。下面的代碼:
Private Sub targetSlideshare()
Dim details() As String
details = accounts(currentAcc).Split(":")
user = details(0)
pass = details(1)
Label19.Text = (currentAcc + 1).ToString + "/" + accounts.Length.ToString
status = "Logout"
Label20.Text = status
loaded2 = False
WebBrowser2.Navigate("https://www.slideshare.net/logout")
While loaded2 = False
Threading.Thread.Sleep(1000)
End While
Threading.Thread.Sleep(1000)
status = "Logging In"
Label20.Text = status
loaded2 = False
WebBrowser2.Navigate("https://www.slideshare.net/login")
While loaded2 = False
Threading.Thread.Sleep(1000)
End While
Threading.Thread.Sleep(5000)
End Sub
Private Sub WebBrowser2_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser2.DocumentCompleted
If WebBrowser2.ReadyState <> WebBrowserReadyState.Complete Then
Exit Sub
End If
If status = "Logout" Then
loaded2 = True
ElseIf status = "Logging In" Then
WebBrowser2.Document.GetElementById("user_login").SetAttribute("value", user)
'WebBrowser2.Document.GetElementById("user_login").SetAttribute("placeholder", Nothing)
WebBrowser2.Document.GetElementById("user_password").SetAttribute("value", pass)
'WebBrowser2.Document.GetElementById("user_password").SetAttribute("placeholder", Nothing)
Dim allelements As HtmlElementCollection = WebBrowser2.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.GetAttribute("value") = "Login" Then
status = "Loading"
webpageelement.InvokeMember("click")
End If
Next
loaded2 = True
End Sub
我沒有麻煩登錄到其他網站,它完美的作品。我只是不明白爲什麼它在幻燈片上的行爲如此。我沒有看到任何代碼錯誤。 此外,移動鏈接只顯示頁面代碼,我不能使用它與網頁瀏覽器。 –