首页 > 编程 > ASP > 正文

两种小偷程序的比较

2024-05-04 11:07:54
字体:
来源:转载
供稿:网友
Function GetURL(url) 
Set Retrieval = CreateObject("Microsoft.XMLHTTP") 
With Retrieval 
.Open "GET", url, False
.Send 
GetURL = bytes2bstr(.responsebody)
'对取得信息进行验证,如果信息长度小于100则说明截取失败
if len(.responsebody)<100 then
response.write "获取远程文件 <a href="&url&" target=_blank>"&url&"</a> 失败。"
response.end
end if
End With 
Set Retrieval = Nothing 
End Function
' 二进制转字符串,否则会出现乱码的!
function bytes2bstr(vin) 
strreturn = "" 
for i = 1 to lenb(vin) 
thischarcode = ascb(midb(vin,i,1)) 
if thischarcode < &h80 then 
strreturn = strreturn & chr(thischarcode) 
else 
nextcharcode = ascb(midb(vin,i+1,1)) 
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode)) 
i = i + 1 
end if 
next 
bytes2bstr = strreturn 
end function 
function savetofile(bodyall,filename)
dim objstream1
set objstream1=createobject("adodb.stream")
objstream1.type=2
objstream1.open
objstream1.position=objstream1.size
objstream1.writetext bodyall
objstream1.savetofile filename,2
objstream1.close
set objstream1=nothing
end function
'声明截取的格式,从Start开始截取,到Last为结束
Function GetKey(HTML,Start,Last)
filearray=split(HTML,Start)
filearray2=split(filearray(1),Last)
GetKey=filearray2(0)
End Function
url="http://www.86516.com"
Html = GetURL(Url)
savetofile html,"ce.htm"

第二种:
</P>
<P>
function gethttppage(url)
dim http
set http=createobject("MICROSOFT.XMLHTTP")
http.open "GET",url,false
http.send()
if http.readystate<>4 then
exit function
end if
gethttppage=bytestostr(http.responseBody,"GB2312")
if err.number<>0 then err.clear
end function</P>
<P>function bytestostr(body,cset)
dim objstream
set objstream=createobject("adodb.stream")
objstream.type=1
objstream.mode=3
objstream.open
objstream.write body
objstream.position=0
objstream.type=2
objstream.charset=cset
bytestostr=objstream.readtext
objstream.close
set objstream=nothing
end function</P>
<P>function savetofile(bodyall,filename)
dim objstream1
set objstream1=createobject("adodb.stream")
objstream1.type=2
objstream1.open
objstream1.position=objstream1.size
objstream1.writetext bodyall
objstream1.savetofile filename,2
objstream1.close
set objstream1=nothing
end function</P>
<P>dim url,http
url="http://www.86516.com"
html=gethttppage(url)
'msgbox html
savefilename="index1.htm"
savetofile html,savefilename</P>
<P>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表