Hello everyone,

Okay probably a simple question, but I'm very green to VBS and I can't
find this anywhere! In the Unix world I use wget to download just the
source file for a given website, but I need to do this same thing in
Windows and preferably with VBS.

Basically what we're doing is downloading an xml file from a vendor's
website then importing it into our MS SQL database via a VBS script
(using QLXMLBulkLoad). I have this part working, but I now need to
download the xml file from the web server. Ideally I'd like to put
this download routine before the code that imports the XML content, but
that's my delimma -- I dunno how to write it :)

Thanks for any suggestions or pointers into the right direction. Take
care --

Alex

Re: Download a website's source with VBS by ljb

ljb
Fri Jun 09 11:35:18 CDT 2006


"Alex" <samalex@gmail.com> wrote in message
news:1149868675.109312.174430@i39g2000cwa.googlegroups.com...
> Hello everyone,
>
> Okay probably a simple question, but I'm very green to VBS and I can't
> find this anywhere! In the Unix world I use wget to download just the
> source file for a given website, but I need to do this same thing in
> Windows and preferably with VBS.
>
> Basically what we're doing is downloading an xml file from a vendor's
> website then importing it into our MS SQL database via a VBS script
> (using QLXMLBulkLoad). I have this part working, but I now need to
> download the xml file from the web server. Ideally I'd like to put
> this download routine before the code that imports the XML content, but
> that's my delimma -- I dunno how to write it :)
>
> Thanks for any suggestions or pointers into the right direction. Take
> care --
>
> Alex
>
I found the follwoing on the web somewhere.

Option Explicit

Const cURL = "http://source.jpg"
Const cOUT = "C:\destination.jpg"

WScript.Echo "Success? " & Fetch(cURL, cOUT)

Function Fetch(xURL, xOUT)
Const adSaveCreateOverWrite = 2

On Error Resume Next
Fetch = False
Err.Clear

Dim objXML, strXML
Set objXML = CreateObject("Microsoft.XMLHTTP")
' Set objXML = CreateObject("MSXML2.XMLHTTP.4.0")
With objXML
.Open "GET", xURL, False
.Send
strXML = .ResponseBody
End With

If Err.Number <> 0 Or objXML.Status <> 200 Then Exit Function

Set objXML = Nothing

Dim objADO
Set objADO = CreateObject("ADODB.Stream")
With objADO
.Open
.Type = 1
.Write strXML
.SaveToFile xOUT, adSaveCreateOverWrite
.Close
End With
Set objADO = Nothing

Fetch = Err.Number = 0
End Function



Re: Download a website's source with VBS by Steve

Steve
Fri Jun 09 11:53:59 CDT 2006

Alex wrote:

> Okay probably a simple question, but I'm very green to VBS and I can't
> find this anywhere! In the Unix world I use wget to download just the
> source file for a given website, but I need to do this same thing in
> Windows and preferably with VBS.

Why not use a Win32 port of wget?
http://www.google.com/search?q=win32+wget

> Basically what we're doing is downloading an xml file from a vendor's
> website then importing it into our MS SQL database via a VBS script
> (using QLXMLBulkLoad). I have this part working, but I now need to
> download the xml file from the web server. Ideally I'd like to put
> this download routine before the code that imports the XML content, but
> that's my delimma -- I dunno how to write it :)

If you want to script it in VBS, you can use the XMLHTTPRequest ActiveX
object. After you get the file, you can use the responseXML.
http://msdn.microsoft.com/library/en-us/xmlsdk/html/7924f6be-c035-411f-acd2-79de7a711b38.asp

--
Steve

If knowledge can create problems, it is not through ignorance that we
can solve them. -Isaac Asimov

Re: Download a website's source with VBS by shb*NO*SPAM*

shb*NO*SPAM*
Fri Jun 09 16:14:03 CDT 2006

On 9 Jun 2006 08:57:55 -0700, "Alex" <samalex@gmail.com> wrote:

>Hello everyone,
>
>Okay probably a simple question, but I'm very green to VBS and I can't
>find this anywhere! In the Unix world I use wget to download just the
>source file for a given website, but I need to do this same thing in
>Windows and preferably with VBS.
>
>Basically what we're doing is downloading an xml file from a vendor's
>website then importing it into our MS SQL database via a VBS script
>(using QLXMLBulkLoad). I have this part working, but I now need to
>download the xml file from the web server. Ideally I'd like to put
>this download routine before the code that imports the XML content, but
>that's my delimma -- I dunno how to write it :)
>
>Thanks for any suggestions or pointers into the right direction. Take
>care --
>
>Alex

I use something like below to get webcam pix.


Set objArgs = WScript.Arguments
url = objArgs(0)
imagefile = objArgs(1)
DestFolder = objArgs(2)

With CreateObject("MSXML2.XMLHTTP")
.open "GET", url, False
.send
a = .ResponseBody
End With

With CreateObject("ADODB.Stream")
.Type = 1 'adTypeBinary
.Mode = 3 'adModeReadWrite
.Open
.Write a
.SaveToFile DestFolder & ImageFile, 2 'adSaveCreateOverwrite
.Close
End With