Re: Avoid loading images - Avoid sounds
- From: "Paul Randall" <paulr901@xxxxxxxxxxxx>
- Date: Mon, 3 Sep 2007 21:17:32 -0600
"McKirahan" <News@xxxxxxxxxxxxx> wrote in message
news:xpadnXXKrrISXEHbnZ2dnUVZ_saknZ2d@xxxxxxxxxxxxxx
"Chris L." <diversos@xxxxxxxxxx> wrote in message
news:1188852551.900837.236710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I'm writing automation scripts in VBA and VBS to use IE6 to retrieve
data from web sites.
I create an instance of IE (or sometimes connect to one instance
already open) and send it commands to navigate to URLs, and retrieve
the data contained in tables etc.
My questions (so far) are:
1) How do I avoid the loading of images? (Ideally the user should be
able to browse normally while my script runs, this means: if the
solutions involves the "display images" option, can it be set to OFF
in one instance without affecting other IE instances?)
2) How to disable the clicking that happens when IE starts navigation?
(again, disabling it in Control Panel shouldn't affect other
instances, ideally)
"... automation scripts in ... VBS ... to retrieve data from web sites."
Have you consider just fetching the page's source without using a
browser? Consider the following script which saves the source of
any URL into a file called "Fetched.vbs" in the current directory.
Option Explicit
'*
Const cVBS = "Fetched.vbs"
Const cTXT = "Fetched.txt"
Const cURL = "http://www.google.com"
'*
Dim strDIR
strDIR = WScript.ScriptFullName
strDIR = Left(strDIR,InStrRev(strDIR,"\"))
Dim strOUT
strOUT = strDIR & cTXT
Dim strURL
strURL = Trim(InputBox("Enter a URL.",cVBS,cURL))
If strURL = "" Then WScript.Quit
MsgBox Fetch(strURL,strOUT),vbInformation,cVBS
Function Fetch(sURL,sOUT)
On Error Resume Next
Err.Clear
'*
Const adSaveCreateOverWrite = 2
Const adTypeBinary = 1
Const adTypeText = 2
'*
Dim objXML
'Set objXML = CreateObject("MSXML2.ServerXMLHTTP.3.0")
Set objXML = CreateObject("Microsoft.XMLHTTP")
objXML.Open "GET", sURL, False
objXML.Send
Dim strXML
strXML = objXML.ResponseBody
If Err.Number <> 0 Or objXML.Status <> 200 Then
Fetch = False
Exit Function
End If
Set objXML = Nothing
'*
Dim objADO
Set objADO = CreateObject("ADODB.Stream")
objADO.Type = adTypeBinary
objADO.Open
objADO.Write strXML
objADO.SaveToFile sOUT, adSaveCreateOverWrite
Set objADO = Nothing
Fetch = Err.Number = 0
End Function
I agree with you fully when you know that the data you are looking for comes
directly from that URL. It bypasses the downloading of unnecessary stuff
like pictures, popup, etc. VBScript can quickly and easily extract the info
from the file you save from the stream. There are cases where you are
redirected to some other URL which actually contains the info of interest.
I haven't found a reliable way to handle this with without letting the
browser do the redirection.
-
.
- Follow-Ups:
- Re: Avoid loading images - Avoid sounds
- From: McKirahan
- Re: Avoid loading images - Avoid sounds
- References:
- Avoid loading images - Avoid sounds
- From: Chris L.
- Re: Avoid loading images - Avoid sounds
- From: McKirahan
- Avoid loading images - Avoid sounds
- Prev by Date: Re: VBScript - String - first letters to Uppercase
- Next by Date: Re: Avoid loading images - Avoid sounds
- Previous by thread: Re: Avoid loading images - Avoid sounds
- Next by thread: Re: Avoid loading images - Avoid sounds
- Index(es):
Relevant Pages
|