I am looking for a VBscript that will open a pre-defined URL and save the
contents to a htm file. Anyone already got it and doesn't mind to share.
Thanks

Re: VBscript to save a web page by Steven

Steven
Thu Jan 06 05:42:30 CST 2005

Dim HTTPObj As MSXML2.XMLHTTP
Dim sURL As String, sPage As String, Lines As Variant

sURL = "http://www.somewhere.com/somepage.htm"
Set HTTPObj = New MSXML2.XMLHTTP
HTTPObj.open "get", sURL, False
HTTPObj.Send
sPage = HTTPObj.responseText

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"An Ben" <someone@microsoft.com> wrote in message
news:41dd20a6$1@news.starhub.net.sg...
> I am looking for a VBscript that will open a pre-defined URL and save the
> contents to a htm file. Anyone already got it and doesn't mind to share.
> Thanks
>
>
>



Re: VBscript to save a web page by An

An
Fri Jan 07 09:00:47 CST 2005

Thanks but I can't get it to work...

it gave this message:

Line : 1
Char : 13
Error : expected end of statement
code : 800A0401
source : microsoft vbscript compilation error


"Steven Burn" <somewhere@in-time.invalid> wrote in message
news:%23hBbzT%238EHA.2316@TK2MSFTNGP15.phx.gbl...
> Dim HTTPObj As MSXML2.XMLHTTP
> Dim sURL As String, sPage As String, Lines As Variant
>
> sURL = "http://www.somewhere.com/somepage.htm"
> Set HTTPObj = New MSXML2.XMLHTTP
> HTTPObj.open "get", sURL, False
> HTTPObj.Send
> sPage = HTTPObj.responseText
>
> --
>
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "An Ben" <someone@microsoft.com> wrote in message
> news:41dd20a6$1@news.starhub.net.sg...
>> I am looking for a VBscript that will open a pre-defined URL and save the
>> contents to a htm file. Anyone already got it and doesn't mind to share.
>> Thanks
>>
>>
>>
>
>



Re: VBscript to save a web page by Torgeir

Torgeir
Fri Jan 07 09:39:21 CST 2005

An Ben wrote:

> I am looking for a VBscript that will open a pre-defined URL and save the
> contents to a htm file. Anyone already got it and doesn't mind to share.
> Thanks
Hi

'--------------------8<----------------------
sURL = "http://www.microsoft.com/"
sDestFile = "f:\tst.htm"

With CreateObject("InternetExplorer.Application")
.Navigate sURL
do until .ReadyState = 4 : wsh.sleep 50 : Loop
sHTML = .document.documentElement.outerHTML
.Quit
End With

' FileSystemObject.CreateTextFile
Const OverwriteIfExist = -1
Const OpenAsASCII = 0

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set f = oFSO.CreateTextFile(sDestFile, OverwriteIfExist, OpenAsASCII)

f.Write(sHTML)
f.Close

'--------------------8<----------------------


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: VBscript to save a web page by mr

mr
Fri Jan 07 17:14:29 CST 2005

hi All,

Steve's code was perfectly good, IF YOU ARE CODING IN VISUAL BASIC!!!

But hey, this is a vbScript ng.

Try this (the same thing converted into vbs):

--- <snip> ---
Const sSource = "http://www.dilbert.com"
Const bGetAsAsync = False ' wait for response
Dim xmlHTTP : Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")
Dim sHTMLPage ' as variant (subtype string)

xmlHTTP.Open "GET", sSource, bGetAsAsync
xmlHTTP.Send ' send it (to the web, wait for result)

sHTMLPage = xmlHTTP.responseText ' (note: as TEXT)
--- </snip> ---

cheers, jw

"Steven Burn" <somewhere@in-time.invalid> wrote in message
news:%23hBbzT%238EHA.2316@TK2MSFTNGP15.phx.gbl...
> Dim HTTPObj As MSXML2.XMLHTTP
> Dim sURL As String, sPage As String, Lines As Variant
>
> sURL = "http://www.somewhere.com/somepage.htm"
> Set HTTPObj = New MSXML2.XMLHTTP
> HTTPObj.open "get", sURL, False
> HTTPObj.Send
> sPage = HTTPObj.responseText
>
> --



Re: VBscript to save a web page by An

An
Fri Jan 07 18:49:01 CST 2005

Thanks... I can run the vbscript without error. However I can't find the
file that was being saved. Am I able to specific the filename and its
location?




"mr unreliable" <ReplyToNewsgroup@notmail.com> wrote in message
news:%238ZTf0Q9EHA.3076@TK2MSFTNGP15.phx.gbl...
> hi All,
>
> Steve's code was perfectly good, IF YOU ARE CODING IN VISUAL BASIC!!!
>
> But hey, this is a vbScript ng.
>
> Try this (the same thing converted into vbs):
>
> --- <snip> ---
> Const sSource = "http://www.dilbert.com"
> Const bGetAsAsync = False ' wait for response
> Dim xmlHTTP : Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")
> Dim sHTMLPage ' as variant (subtype string)
>
> xmlHTTP.Open "GET", sSource, bGetAsAsync
> xmlHTTP.Send ' send it (to the web, wait for result)
>
> sHTMLPage = xmlHTTP.responseText ' (note: as TEXT)
> --- </snip> ---
>
> cheers, jw
>
> "Steven Burn" <somewhere@in-time.invalid> wrote in message
> news:%23hBbzT%238EHA.2316@TK2MSFTNGP15.phx.gbl...
>> Dim HTTPObj As MSXML2.XMLHTTP
>> Dim sURL As String, sPage As String, Lines As Variant
>>
>> sURL = "http://www.somewhere.com/somepage.htm"
>> Set HTTPObj = New MSXML2.XMLHTTP
>> HTTPObj.open "get", sURL, False
>> HTTPObj.Send
>> sPage = HTTPObj.responseText
>>
>> --
>
>



Re: VBscript to save a web page by McKirahan

McKirahan
Fri Jan 07 19:08:22 CST 2005

"An Ben" <someone@microsoft.com> wrote in message
news:41dd20a6$1@news.starhub.net.sg...
> I am looking for a VBscript that will open a pre-defined URL and save the
> contents to a htm file. Anyone already got it and doesn't mind to share.
> Thanks

Will this help? Watch for word-wrap.

Option Explicit
'*
Const cVBS = "getURL.vbs"
Const cHTM = "getURL.htm"
Const cURL = "http://www.google.com/index.html"
'*
Dim strXML
'*
Dim objXML
'* Set objXML = CreateObject("MSXML2.XMLHTTP")
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", cURL, False
objXML.Send
strXML = objXML.ResponseText
Set objXML = Nothing
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Set objOTF = objFSO.OpenTextFile(cHTM,2,True)
objOTF.WriteLine(strXML)
Set objOTF = Nothing
Set objFSO = Nothing



Re: VBscript to save a web page by An

An
Fri Jan 07 19:26:16 CST 2005

Why am I getting this error:
Invalid procedure call or argument
at this line:
f.Write(sHTML)

Any idea?
Thanks


>
> '--------------------8<----------------------
> sURL = "http://www.microsoft.com/"
> sDestFile = "f:\tst.htm"
>
> With CreateObject("InternetExplorer.Application")
> .Navigate sURL
> do until .ReadyState = 4 : wsh.sleep 50 : Loop
> sHTML = .document.documentElement.outerHTML
> .Quit
> End With
>
> ' FileSystemObject.CreateTextFile
> Const OverwriteIfExist = -1
> Const OpenAsASCII = 0
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
>
> Set f = oFSO.CreateTextFile(sDestFile, OverwriteIfExist, OpenAsASCII)
>
> f.Write(sHTML)
> f.Close
>
> '--------------------8<----------------------
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx



Re: VBscript to save a web page by Michael

Michael
Fri Jan 07 19:43:29 CST 2005

An Ben wrote:
> Why am I getting this error:
> Invalid procedure call or argument
> at this line:
> f.Write(sHTML)
>
> Any idea?

Post the *exact* script that *you* are executing. The posted example works
exactly as expected, assuming you have adjusted the path to one that exists
on your machine...

--
Michael Harris
Microsoft MVP Scripting



Re: VBscript to save a web page by Torgeir

Torgeir
Mon Jan 10 05:03:04 CST 2005

An Ben wrote:

> "mr unreliable" <ReplyToNewsgroup@notmail.com> wrote:
>
>>Steve's code was perfectly good, IF YOU ARE CODING IN VISUAL BASIC!!!
>>
>>But hey, this is a vbScript ng.
>>
>>Try this (the same thing converted into vbs):
>>
>>--- <snip> ---
>>Const sSource = "http://www.dilbert.com"
>>Const bGetAsAsync = False ' wait for response
>>Dim xmlHTTP : Set xmlHTTP = CreateObject("Microsoft.XMLHTTP")
>>Dim sHTMLPage ' as variant (subtype string)
>>
>> xmlHTTP.Open "GET", sSource, bGetAsAsync
>> xmlHTTP.Send ' send it (to the web, wait for result)
>>
>> sHTMLPage = xmlHTTP.responseText ' (note: as TEXT)
>>--- </snip> ---
>
> Thanks... I can run the vbscript without error. However I can't
> find the file that was being saved. Am I able to specific the
> filename and its location?
Hi

That's because the script by jw is not saving the text to a file,
it just puts the content of the web page into the variable sHTMLPage.
You will need to add the saving to a file yourself.


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx