dim oCollection, oCollection=webbrowser1.document.getElementsByTagName("A") 这个oCollection就是所有A链接的数组集合,然后搞个集合长度内的随机数字k oCollection(k).click;
For Each Web In WebBrowser.Document.links If InStr(Web.href, "http://") Then If InStr(adStr, Web.href & vbCrLf) = 0 Then ReDim Preserve Arr(a) Arr(a) = Web.href a = a + 1 adStr = adStr & Web.href & vbCrLf End If End If Next Web y = intRnd(UBound(Arr), 0)
For n = 0 To WebBrowser.Document.All.Length - 1 If UCase(WebBrowser.Document.All(n).tagName) = "A" Then If WebBrowser.Document.All(n).href = Arr(y) Then WebBrowser.Document.All(n).Click Exit Sub End If End If Next n
Private Function intRnd(ByVal up As Integer, ByVal lo As Integer) As Integer Randomize intRnd = Int((up - lo + 1) * Rnd + lo) End Function 我来接分的
oCollection=webbrowser1.document.getElementsByTagName("A")
这个oCollection就是所有A链接的数组集合,然后搞个集合长度内的随机数字k
oCollection(k).click;
If InStr(Web.href, "http://") Then
If InStr(adStr, Web.href & vbCrLf) = 0 Then
ReDim Preserve Arr(a)
Arr(a) = Web.href
a = a + 1
adStr = adStr & Web.href & vbCrLf
End If
End If
Next Web y = intRnd(UBound(Arr), 0)
For n = 0 To WebBrowser.Document.All.Length - 1
If UCase(WebBrowser.Document.All(n).tagName) = "A" Then
If WebBrowser.Document.All(n).href = Arr(y) Then
WebBrowser.Document.All(n).Click
Exit Sub
End If
End If
Next n
Randomize
intRnd = Int((up - lo + 1) * Rnd + lo)
End Function
我来接分的