Function GetURL(url)Set Retrieval = CreateObject(Microsoft.XMLHTTP)With Retrieval.Open GET, url, False.SendGetURL = bytes2bstr(.responsebody)'對取得資訊進行驗證,如果資訊長度小於100則表示截取失敗if len( .responsebody)<100 thenresponse.write 取得遠端檔案<a href=&url& target=_blank>&url&</a> 失敗。 response.endend ifEnd WithSet Retrieval = NothingEnd Function' 二進位轉字串,否則會出現亂碼的! function bytes2bstr(vin)strreturn = for i = 1 to lenb(vin)thischarcode = ascb(midb(vin,i,1))if thischarcode < &h80 thenstrreturn = strreturn & chr(thischarcode)elsenextcharcode = ascb(midb(vin,i +1,1))strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))i = i + 1end ifnextbytes2bstr = strreturnend functionfunction savetofile(bodyall,filename)dim objstream1set objstream1=createobject(adodb.stream)objstream1.ob51.1555pstream bodyallobjstream1.savetofilename,2objstream1.closeset objstream1=nothingend function'宣告截取的格式,從Start開始截取,到Last為結束Function GetKey(HTML,Start,Last)filearray=split(HTML,Start)arrayarray2=split(arrafiley2=plit) 1),Last)GetKey=filearray2(0)End Functionurl=http://www.86516.comHtml = GetURL(Url)savetofile html,ce.htm
第二種:
</P><P>function gethttppage(url)dim httpset http=createobject(MICROSOFT.XMLHTTP)http.open GET,url,falsehttp.send()if http.readystate<>4 thenexit functionend ifgethttppage=bytestostr(http.responseBody ,GB2312)if err.number<>0 then err.clearend function</P><P>function bytestostr(body,cset)dim objstreamset objstream=createobject(adodb.stream)objstream.type=1objstream.mode=3objstream.openobjstream.write bodyobjstream.position=0objstream.chartype=2jstream. csetbytestostr=objstream.readtextobjstream.closeset objstream=nothingend function</P><P>function savetofile(bodyall,filename)dim objstream1set objstream1=createobject(adodb.stream)objstream1.type=2objstream1.openobjstream1.position=objstream1.sizeobjstream1. filename,2objstream1.closeset objstream1=nothingend function</P><P>dim url,httpurl=http://www.86516.comhtml=gethttppage(url)'msgbox htmlsavefilename=index1.htmsavetofile html,savefilename</P>< P>