Fonction GetURL(url)Set Retrieval = CreateObject(Microsoft.XMLHTTP)With Retrieval.Open GET, url, False.SendGetURL = bytes2bstr(.responsebody)'Vérifiez les informations obtenues si la longueur des informations est inférieure à 100, l'interception échoue si. len( .responsebody)<100 thenresponse.write Obtenir le fichier distant<a href=&url& target=_blank>&url&</a> a échoué. réponse.endend ifEnd WithSet Retrieval = NothingEnd Function' Binaire en chaîne, sinon des caractères tronqués apparaîtront ! fonction bytes2bstr(vin)strreturn = pour i = 1 à lenb(vin)thischarcode = ascb(midb(vin,i,1))si 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.type=2objstream1.openobjstream1.position=objstream1.sizeobjstream1.writetext bodyallobjstream1.savetofile filename,2objstream1.closeset objstream1=nothingend function' déclare le format d'interception, commençant à Start et se terminant à Last Function GetKey(HTML,Start,Last)filearray=split(HTML,Start)filearray2=split(filearray(1), Last) GetKey=filearray2(0)Fin Functionurl=http://www.86516.comHtml = GetURL(Url)savetofilehtml,ce.htm
Deuxième type :
</P><P>fonction 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)si err.number<>0 alors fonction err.clearend</P><P>fonction bytestostr(body,cset)dim objstreamset objstream=createobject(adodb.stream)objstream.type=1objstream.mode=3objstream.openobjstream.write bodyobjstream.position=0objstream.type=2objstream.charset=csetbytestostr=objstream.readtextobjstream.closeset objstream= fonction Nothingend</P><P>fonction savetofile(bodyall,filename)dim objstream1set objstream1=createobject(adodb.stream)objstream1.type=2objstream1.openobjstream1.position=objstream1.sizeobjstream1.writetext bodyallobjstream1.savetofile filename,2objstream1.closeset objstream1=nothingend function</P><P> faible url,httpurl=http://www.86516.comhtml=gethttppage(url)'msgbox htmlsavefilename=index1.htmsavetofile html,savefilename</P><P>