Topic Options
#1311 - 11/23/03 01:05 AM Download files from http (not from ftp!)
weatherboys Offline
Member

Registered: 11/23/03
Posts: 47
What I would like to do is the following.
I am a meteorologist and I want to e.g. set up an archive of surface maps from Bracknell that can be found at the following URL: http://129.13.102.67/wz/pics/bracka.gif
(other gifs have names like: brack0, brack1a etc.)

How do I do that (examples are always related to FTP)?

Please help. Thanks in advance.
John

Top
#1312 - 11/23/03 12:06 PM Re: Download files from http (not from ftp!)
Luke Tomasello Administrator Online   content
Member

Registered: 09/17/00
Posts: 739
Loc: San Jose, CA., USA
Not a problem if you're using WinCron 4.0!
(New BETA version available for download now.)

Code:
  
## Grab an image from a website
# 
# Adapted from a script by Michael Harris
# Microsoft.MVP.Scripting
{
	-start
	-stop
	
	GetImage("bracka.gif")
	Print("Done! at %c%")
}

Function GetImage(args)

	sSrcUrl = "http://129.13.102.67/" & "wz/pics/"

	sImageFile = args

	sContentTypeExpected = "image/gif"

	sDestFolder = "c:\temp\"

	set oHTTP = CreateObject("msxml2.XMLHTTP")

	oHTTP.open "GET", sSrcUrl & sImageFile, False
	oHTTP.send

	if oHTTP.status <> 200 then
		msgbox "unexpected status = " & oHTTP.status & vbcrlf & oHTTP.statusText
		Exit Function
	end if

	sContentTypeReturned = oHTTP.getResponseHeader("content-type")

	if sContentTypeReturned <> sContentTypeExpected then
		msgbox "unexpected content-type = " & sContentTypeReturned & vbcrlf & "expected = " & sContentTypeExpected
		Exit Function
	end if


	set oStream = createobject("adodb.stream")
	Const adTypeBinary = 1
	Const adSaveCreateOverWrite = 2
	oStream.type = adTypeBinary
	oStream.open
	oStream.write oHTTP.responseBody
	oStream.savetofile sDestFolder & sImageFile, adSaveCreateOverWrite

End Function
_________________________
Regards,
Luke Tomasello

Top


Moderator:  Luke Tomasello