'随机取板块的某一个链接,并且点击
Set webTable=ie.Document.getElementsByTagName("Table")
Set webtableRows=webtable.item(1).getElementsByTagName("TR")
i=genRand(webtableRows.length)
Set tablelink=webtableRows.item(i).getElementsByTagName("a")
tablelink.item(1).click
delay(ie)
'获取帖子中iframe中的某一个对象,重新打开一个链接,并获取link对象,然后点击
Set iframes=ie.Document.getElementsByTagName("iframe")
i=genRand(iframes.length)
ie.Navigate iframes.item(i).src
delay(ie)
Set googlelink=ie.Document.getElementsByTagName("a")
googlelink.item(0).click
'MsgBox tablelink.length
'ie.Document.parentwindow.close
ie.Quit
Set googlelink=Nothing
Set iframes=Nothing
Set webtableRows=Nothing
Set webTable=Nothing
Set searchLink=Nothing
Set linkAll=Nothing
Set ie=Nothing
Function GetLink(objects,name)
For Each obj In objects
tmp=obj.innertext
'MsgBox tmp
If Len(tmp)>0 Then
If RegExpTest(obj.innertext,name) Then
Set GetLink=obj
Exit For
End If
End If
Next
End Function
Function RegExpTest(patrn, strng)
Dim regEx, retVal ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = False ' Set case sensitivity.
retVal = regEx.Test(strng) ' Execute the search test.
RegExpTest=retVal
End Function
Sub delay(obj)
Do
WScript.Sleep 5
Loop Until CInt(obj.readyState)=4
' MsgBox CInt(obj.readyState)
End Sub
Function genRand(count)
genRand=Int(Rnd() * count)
End Function