用ASP VBS xmlhttp adodbstream下载和保存图片的代码(2)
Astream.Writetext data,1
else
Astream.Write data
end if
Astream.SaveToFile recfilen,2
Astream.close
end function
'Server.
function downimg(url)
set oXMLHTTP =CreateObject("Microsoft.XMLHTTP")'asp Server.CreateObject("Microsoft.XMLHTTP")
data_got=""
oXMLHTTP.open "GET",url, false
oXMLHTTP.setRequestHeader "Accept-Encoding"," gzip, deflate"
oXMLHTTP.setRequestHeader "User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 2.0.50727)"
oXMLHTTP.send
rtstatus=oXMLHTTP.status
data_got=oXMLHTTP.responsebody
filename=mid(url,InStrRev(url,"/")+1)
if rtstatus=200 then
data_got=oXMLHTTP.responsebody
saveFile data_got,filename
else
data_got=""
end if
set oXMLHTTP =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
内容版权声明:除非注明,否则皆为本站原创文章。