所以我基本上制作了一个代码来跟踪推特上的人,如果我点击我的按钮我会跟随10个人点击一下。 没问题,如果我在我的vb中向下滚动。 webbrowser所以我得到一个约200-300人的列表,我想用我的按钮跟随他们 我的程序不再响应了。我认为因为只需点击一下按钮就会点击太多。 那么我怎么能像一个人一样跟随另一个人呢,依此类推?而不是所有人都在同一时间?
我的代码:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("https://twitter.com/YG/followers")
Dim Rect As Rectangle = Me.WebBrowser1.Document.Body.ScrollRectangle
Dim BodySize As New Size(Rect.Width, Rect.Height)
Me.WebBrowser1.Size = BodySize
End Sub
Declare Sub Sleep Lib "kernel32.dll" (ByVal Milliseconds As Integer)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
'<button class="user-actions-follow-button js-follow-btn follow-button btn small small-follow-btn"
'button-text follow-text
If webpageelement.GetAttribute("className") = "button-text follow-text" Then
webpageelement.InvokeMember("click")
webpageelement.InvokeMember("MouseDown")
webpageelement.InvokeMember("MouseUp")
webpageelement.RaiseEvent("OnClick")
webpageelement.Focus()
If webpageelement.GetAttribute("className") = "button-text following-text" Then
End If
End If
Next
End Sub