Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Downloading a specific file on a web page. 1

Status
Not open for further replies.

pxm148

Programmer
Jan 6, 2005
12
CA
I would like to be able to download a file on a website.
Here what I'm trying to use:

Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")

objExplorer.Navigate "
But that only displays the page on the IE window. I would like to download the file instead.

Thanks
 
pxm148,

If it is a txt file, then this will do if you want to save it to what specified in the variable filespec.
Code:
filespec="d:\test\abc.txt"    'set it to your need

'These two are your lines. Written as such for whatever reason.
[green]Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
objExplorer.Navigate "[URL unfurl="true"]http://www.google.com/file.txt"[/URL][/green]

do while objExplorer.readystate<>4 : wscript.sleep 50 : loop
s=objExplorer.document.body.innerText

'if you don't want to quit, comment out these two lines
objExplorer.quit
set objExplorer=nothing

set fso=createobject("scripting.filesystemobject")
set ofile=fso.createtextfile(filespec,true)
ofile.write s
ofile.close
set ofile=nothing
set fso=nothing
regards - tsuji
 
I found how to do it:
PageContain = objExplorer.document.body.innerText
 
Oups I didn't see your reply when I posted mine, Thanks for the help anyway...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top