Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Download web page into file not work

9 views
Skip to first unread message

moonhk

unread,
Oct 20, 2009, 12:07:24 PM10/20/09
to
Hi All

Why this not work objOutputFile.Write(PageCache) ? I want daily
download this web page and grep particular data on the file.

Any suggest ?

Below Script copy from Internet.

'~~ ie_down01.vbs
'Option Explicit
Dim WshShell
Dim oIE
Dim PageCache
dim objFileSystem
dim objOutputFile
dim document

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = true
oIE.Navigate "http://baby.boom.com.hk/portfolio/IPO/list.asp"

Do While oIE.Busy Or (oIE.READYSTATE <> 4)
Wscript.Sleep 10
Loop

'Do search
'oIE.document.forms(0).elements("g").Value = "wombat"
'oIE.document.forms(0).submit

Do While oIE.Busy Or (oIE.READYSTATE <> 4)
Wscript.Sleep 10
Loop

'Write results to a text file

PageCache = oIE.document.body.innerHTML

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile("c:\temp
\wombat_cache1.html", TRUE)

objOutputFile.Write(PageCache)

objOutputFile.Close

Al Dunbar

unread,
Oct 20, 2009, 10:18:41 PM10/20/09
to

"moonhk" <moo...@gmail.com> wrote in message
news:7c97f05c-14e2-400f...@z4g2000prh.googlegroups.com...

> Hi All
>
> Why this not work objOutputFile.Write(PageCache) ?

Are you expecting us to run it to see what happened when you ran it? If you
want help on this I'd suggest that you describe what does happen when you
run this script. For example, does it hang up and fail to complete, produce
an error message, fail to create the html file you are expecting, or
something else?

/Al

moonhk

unread,
Oct 21, 2009, 3:00:29 AM10/21/09
to
On 10月21日, 上午10時18分, "Al Dunbar" <aland...@hotmail.com> wrote:
> "moonhk" <moon...@gmail.com> wrote in message
> > objOutputFile.Close- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

C:\Temp>dir wo*
Volume in drive C has no label.
Volume Serial Number is 9097-2007

Directory of C:\Temp

10/21/2009 14:57 0 wombat_cache1.html
1 File(s) 0 bytes
0 Dir(s) 5,961,515,008 bytes free


With below error in objOutputFile.Write(PageCache)

C:\Temp>ie_down01.vbs
X:\HOME\EXAMPLE\SOFTWARE\SHELL\ie_down01.vbs(34, 1) Microsoft VBScript
runtime error: Invalid procedure call or argument


C:\Temp>

Pegasus [MVP]

unread,
Oct 21, 2009, 7:55:19 AM10/21/09
to
"moonhk" <moo...@gmail.com> wrote in message
news:4d088613-148a-4953...@x6g2000prc.googlegroups.com...
> > objOutputFile.Close- ���óQ�ޥΤ�r -
>
> - ��ܳQ�ޥΤ�r -

C:\Temp>dir wo*
Volume in drive C has no label.
Volume Serial Number is 9097-2007

Directory of C:\Temp

10/21/2009 14:57 0 wombat_cache1.html
1 File(s) 0 bytes
0 Dir(s) 5,961,515,008 bytes free


With below error in objOutputFile.Write(PageCache)

C:\Temp>ie_down01.vbs
X:\HOME\EXAMPLE\SOFTWARE\SHELL\ie_down01.vbs(34, 1) Microsoft VBScript
runtime error: Invalid procedure call or argument


C:\Temp>

===============

News readers often split long lines into two lines. To save respondents the
trouble of guessing which is Line 34, you should take the time to post the
actual line that causes the problem.


Tom Lavedas

unread,
Oct 21, 2009, 8:18:09 AM10/21/09
to

The problem is that your page contains Unicode characters (2 bytes per
character) and the file is being opened as an ASCII formatted file (1
bytes per character). Fix the CreateTestFile to designate the
objOutputFile as Unicode (add a third argument set to True) and it
should work (assuming there is an existing folder named 'temp' on C:
\) ...

Set objOutputFile = objFileSystem.CreateTextFile("c:\temp

\wombat_cache1.html", TRUE, true)
_____________________
Tom Lavedas

moonhk

unread,
Oct 21, 2009, 10:42:38 AM10/21/09
to
Thank . It works.

Try "http://www.ibm.com/us/en/", still need the third parameter.

'~~ ie_down01.vbs
Option Explicit
'not work Download http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22786372.html


Dim WshShell
Dim oIE
Dim PageCache
dim objFileSystem
dim objOutputFile
dim document

Set WshShell = WScript.CreateObject("WScript.Shell")
Set oIE = CreateObject("InternetExplorer.Application")

oIE.Visible = false
'oIE.Navigate "http://baby.boom.com.hk/portfolio/IPO/list.asp"
oIE.Navigate "http://www.ibm.com/us/en/"


Do While oIE.Busy Or (oIE.READYSTATE <> 4)
Wscript.Sleep 10
Loop

'Do search
'oIE.document.forms(0).elements("g").Value = "wombat"
'oIE.document.forms(0).submit

Do While oIE.Busy Or (oIE.READYSTATE <> 4)
Wscript.Sleep 10
Loop

'Write results to a text file

PageCache = oIE.document.body.innerHTML
' msgbox len(pagecache)


Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile("c:\temp

\wombat_cache1.html", TRUE,true)

objOutputFile.Write(PageCache)
objOutputFile.Close

Si Ballenger

unread,
Oct 24, 2009, 2:27:18 AM10/24/09
to
On Tue, 20 Oct 2009 09:07:24 -0700 (PDT), moonhk
<moo...@gmail.com> wrote:

>Hi All
>
>Why this not work objOutputFile.Write(PageCache) ? I want daily
>download this web page and grep particular data on the file.
>
>Any suggest ?

See if the below gets the page source.

testload.vbs
============================

With CreateObject("MSXML2.XMLHTTP")
.open "GET", "http://baby.boom.com.hk/portfolio/IPO/list.asp",
False
.send
a = .ResponseBody
End With
With CreateObject("ADODB.Stream")
.Type = 1 'adTypeBinary
.Mode = 3 'adModeReadWrite
.Open
.Write a
.SaveToFile "pagesource.txt", 2 'adSaveCreateOverwrite
.Close
End With

0 new messages