Function:
Copy Code code as follows:
function SaveFile (Data,recfilen)
Set Astream=createobject ("ADODB.stream") ' ASP Server.CreateObject (' ADODB.stream ')
Fxt=mid (Recfilen,instrrev (Recfilen, ".") +1)
Txt=false
If fxt= "ASP" or "fxt=" xml or fxt= "aspx" or fxt= "PHP" or fxt= "txt" or fxt= "JSP" then
Txt=true
End If
If TXT then
astream.type=2 ' 1 bin,2 txt
Else
Astream.type=1 ' 1 bin,2 txt
End If
Astream.mode = 3 ' adModeRead =1
' adModeReadWrite =3
' Admoderecursive =4194304
' adModeShareDenyNone =16
' adModeShareDenyRead =4
' adModeShareDenyWrite =8
' Admodeshareexclusive =12
' adModeUnknown =0
' adModeWrite =2
Astream.open
' Astream.charset = ' GB2312 '
' Astream.loadfromfile (recfilen) ' Loading file
' Assp=astream.size
astream.position = 0 ' set to ASSP when loading files
' Astream.writetext tmpstr00,1
If TXT then
DATA=BYTES2BSTR (data)
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) ' binary conversion to Chinese characters
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
How to use:
Copy Code code as follows:
Imgurl= "http://www.163car.com/UpFile/CarImages/0092/S_b_20051241127326f6uew1s.jpg" pictures
Downimg (Imgurl)
Imgurl= "HTTP://login.zydn.net/news.asp" text page
Downimg (Imgurl)
Save the code as a VBS file and run it without the need for IIS.