Chris
Tue Sep 04 12:54:46 PDT 2007
On 3 sep, 23:26, "McKirahan" <N...@McKirahan.com> wrote:
> "Chris L." <diver...@uol.com.ar> wrote in message
>
> news:1188852551.900837.236710@d55g2000hsg.googlegroups.com...
>
>
>
>
>
> > 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- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
Hello, thanks for the useful script; it will come in handy for another
project I have.
But, as my first question is concerned, I need the browser interaction
because I have to fill in fields, position comboboxes, check some
boxes, then press a button, wait for search results to display, then
store the resulting data, all automatically.
Can I assume there is no way to keep the images from loading? (I have
searched the NGs to no avail)
Regards
Chris