Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
; here's the basic download using OLE. ; ; I'll leave you to write the WinInet Code to do the actual image downloads, ; and make any changes...it's interactive to start, then you can modify it ; to make it "auto-magic" ;) ; Winbatch 2004F, MSIE 6 #DefineSubRoutine startMSIE(url) browser = ObjectOpen("InternetExplorer.Application") browser.addressbar = @FALSE browser.statusbar = @FALSE browser.menubar = @FALSE browser.toolbar = @FALSE browser.visible = @FALSE browser.navigate(url) ; wait until page loads... 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 ; load WinInet extender AddExtender("wwint34i.dll") ; URL of page you wish to Download... ;url = "C:\Test\Winbatch Main Page.htm" url = "http://www.winbatch.com" ;<--- modify to the page you need... ; ; specify the folder you wish to store the pages in... DownloadFolder = "c:\temp\webpage" ;<--- modify to your own location... ; ; check for trailing backslash if StrSub(DownloadFolder,StrLen(DownloadFolder),1) != "\" then DownloadFolder = StrCat(DownloadFolder,"\") ; ; start the browser... br = startMSIE(url) ; ; build a current filename from the .title of the current page... cfname = StrTrim(browserdoc.title) If StrSub(cfname, StrLen(cfname), 1) == "." cfname = StrCat(DownloadFolder, cfname, "htm") Else cfname = StrCat(DownloadFolder, cfname, ".htm") EndIf ; double check with the user... filename = AskLine("Debug", "SAVE AS FILENAME", cfname) ; ; build an image folder inside the download folder... imageFolder = StrCat(DownloadFolder, FileRoot(filename),"_Files\") ; make the new folder... DirMake(imageFolder) ; ; open WinInet session tophandle=iBegin(0,"","") ; ; loop thru the images on the page and grab... ImageList = browserdoc.GetElementsBytagName("IMG") For x = 0 To ImageList.length-1 thisImage = ImageList.item(x) ; the source image... thisSRC = thisImage.SRC ; only the filename for the destination filename... thisIMG = ItemExtract(ItemCount(thisSRC, "/"), thisSRC, "/") ; download image file datahandle=iUrlOpen(tophandle,thisSRC) xx=iReadData(datahandle,StrCat(imageFolder,thisIMG)) ; specify relative image path thisImage.SRC = StrCat(FileRoot(filename),"_Files\", thisIMG) ; close object ObjectClose(thisImage) Next ; loop thru the background images on the page and grab... BackImageList = browserdoc.GetElementsBytagName("table") For y = 0 To BackImageList.length-1 thisBackImage = BackImageList.item(y) ; the source image... thisBackSRC = thisBackImage.background if thisBackSRC=="" then continue ; only the filename for the destination filename... thisBackIMG = ItemExtract(ItemCount(thisBackSRC, "/"), thisBackSRC, "/") ; download image file datahandle=iUrlOpen(tophandle,thisBackSRC) xx=iReadData(datahandle,StrCat(imageFolder,thisBackIMG)) bck = StrCat(FileRoot(filename),"_Files\", thisBackIMG) ; specify relative image path thisBackImage.background = bck ; close object ObjectClose(thisBackImage) Next ; close WinInet session iClose(datahandle) iClose(tophandle) ; now grab the HTML from the page... body = browserdoc.body bodytxt = body.outerHTML ; strcat a comment to the top of it, with the URL of the page just in case ; you need it later... bodytxt = StrCat("", @CRLF, bodytxt, "") ; ; write the new HTML to the file... FilePut(filename, bodytxt) ; Message("Debug", "All Done") Return Exit
Article ID: W16133
File Created: 2004:08:02:11:24:20
Last Updated: 2004:08:02:11:24:20