WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

WebPage Inventory


;   Try this, it gives a short "inventory" of a webpage. It'll show
;   you what's on the page, and how many of each.

;   Hint: use this to build something more detailed, like summaries
;   for each table (whether they have borders and their size, how many
;   rows/cells in each one) and so on for each. Look at the images
;   collection (figure out how many are .GIF, .JPG, etc, etc).

;   this uses Winbatch 2004F and MSIE 6...

;   when you run this let it sit while the page loads completely...

#DefineSubRoutine startMSIE()
   Browser = ObjectOpen("InternetExplorer.Application")
   Browser.addressbar = @FALSE
   Browser.statusbar = @FALSE
   Browser.menubar = @FALSE
   Browser.toolbar = @FALSE
   browser.visible = @TRUE
   url = "http://www.windowware.com"        ;  <--------- Set to URL you prefer...
   browser.navigate(url)
   WaitForPageLoad()
   ;   setup the document object...
   browserDoc = Browser.Document
   all = browserdoc.all
   Return(browser)
#EndSubRoutine

#DefineSubroutine WaitForPageLoad()  ; assume Browser
   While browser.busy || browser.readystate == 1
      TimeDelay(0.5)
   EndWhile
   While browser.Document.ReadyState != "complete"
      TimeDelay(0.5)
   EndWhile
   return
#EndSubroutine



;   set up what to do if the browser is closed before the script ends...
IntControl(73, 1, 0, 0, 0)

;   start the browser...
br = startMSIE()

Message("Objects on this Page", all.length)

objlist = ""
objcount= ""

For x = 0 To all.length-1
   dp = all.%x%
   location = ItemLocate(dp.tagname, objlist, @TAB)
   If location == 0
      objlist = ItemInsert(dp.tagname, -1, objlist, @TAB)
      objcount= ItemInsert("1", -1, objcount, @TAB)
   Else
      count   = ItemExtract(location, objcount, @TAB)
      objcount= ItemReplace(count+1, location, objcount, @TAB)
   EndIf
Next

finaltxt = ""
sortlist = ItemSort(objlist, @TAB)

For x = 1 To ItemCount(objlist, @TAB)
   thisobj = ItemExtract(x, sortlist, @TAB)
   usloc   = ItemLocate(thisobj, objlist, @TAB)
   thiscnt = ItemExtract(usloc, objcount, @TAB)
   finaltxt = StrCat(finaltxt, thisobj, @TAB, thiscnt, @CRLF)
Next

Message("Page Inventory & Count", finaltxt)

:WBERRORHANDLER

Return
Exit

Article ID:   W16137
File Created: 2004:08:02:11:25:20
Last Updated: 2004:08:02:11:25:20