前一陣子玩模擬精靈,裏面有一段代碼可以自動踩百度博客,增加回訪,代碼緊湊細緻,效率極高。今天下午忽發奇想,用vbs來實現一下自動踩百度博客。儘管實現了,但是總感覺走了彎路,沒有模擬精靈效率高,方法簡潔。因爲是用於演示,所以只收集了9個頁面的博客地址,每次訪問也是從頭開始,有興趣的朋友,可以自己修改相應的代碼。希望百度管理員不要封我,我沒有惡意,呵呵。
code1:
On Error Resume Next
url="http://hi.baidu.com/hi/good0"
'str="http://hi.baidu.com.xuejinglan"
Set ie=WScript.CreateObject("InternetExplorer.Application")
ie.visible=True
atlink=""
For i=1 To 9 Step 1
urll=url & i &".html"
ie.navigate urll
While ie.Busy
WScript.Sleep 100
Wend
Set links=ie.Document.links
Set fso = CreateObject("Scripting.FileSystemObject")
Set f=fso.OpenTextFile("c:/url.txt",8,True)
For Each link In links
If link<>atlink And link<>"http://www.baidu.com/" And
link<>"http://hi.baidu.com/"
And link<>"http://www.baidu.com/search/hi_contract.html" And
link<>"http://www.baidu.com/duty/" And reg(link)<>true Then f.WriteLine link
atlink=link
Next
f.Close
Next
Function reg(str)
Dim regEx, Match, Matches
Set regEx = New RegExp
regEx.Pattern = "^http://hi.baidu.com/hi/good"
regEx.IgnoreCase = True
regEx.Global = True
Val = regEx.Test(str)
reg =Val
End Function
將此段代碼保存爲:取得地址.vbs,執行可得到百度空間各博客的地址。
code2:
'str="http://hi.baidu.com.xuejinglan"
Set Wshell=WScript.CreateObject("WScript.Shell")
Set ie=WScript.CreateObject("InternetExplorer.Application")
ie.visible=true
ie.navigate "http://passport.baidu.com/"
Do
Wscript.Sleep 200
Loop Until ie.ReadyState=4
ie.document.getElementById("username").value="xxxxxxx"
ie.document.getElementById("password").value="*******"
tj=ie.document.getElementsBytagname("form")
tj.submit
WScript.Sleep 10000
Set fso = CreateObject("Scripting.FileSystemObject")
Set f=fso.OpenTextFile("c:/url.txt",1,false)
Do While f.AtEndOfLine <> True
url=f.ReadLine
Set ie=WScript.CreateObject("InternetExplorer.Application")
ie.visible=True
ie.navigate url
Do
Wscript.Sleep 200
Loop Until ie.ReadyState=4
WScript.Sleep 10000
ie.Quit
Loop
將此段代碼保存爲:踩空間.vbs,執行即可。