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
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
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>
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.
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
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
>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