【ahk】获取网站的源代码

用AutoHotkey来获取网站的源代码:

WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
WebRequest.Open("GET", "http://www.baidu.com")  ;必须有http://
WebRequest.Send()
result := WebRequest.ResponseText
MsgBox  % result
Clipboard:=result

vbs版本

Set oDOM=WScript.GetObject("http://www.baidu.com")'就是取得这个对象 
Do Until oDOM.readyState="complete" '一直循环等待200ms,直到页面加载完成 
WScript.sleep 50'就是等待200ms 
Loop 
WScript.echo oDOM.documentElement.outerText'取得某个文本,并弹出对话框以显示此消息 
Set oDOM=nothing'断开与对象的连接以释放内存。

另一个ahk方法

pwb := ComObjCreate("InternetExplorer.Application")
pwb.Navigate("baidu.com") 
   Loop   ;Otherwise sleep for .1 seconds untill the page starts loading
      Sleep,100
   Until (Pwb.busy)
   Loop   ;Once it starts loading wait until completes
      Sleep,100
   Until (!Pwb.busy)
   Loop   ;optional check to wait for the page to completely load
      Sleep,100
   Until (Pwb.Document.Readystate = "Complete")
MsgBox,% pwb.Document.body.innerHTML

你可能感兴趣的:(【ahk】获取网站的源代码)