Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
; Winbatch 2005B - Analyze Page Links [Internet Explorer] ; ; This script works with pages that have been saved to a local ; .htm file - basically you can choose the DHTML elements you ; wish and the script will enumerate each element and ; important attributes. ; ; Assuming you main explorer object is oIE, it also writes a code ; snippet for that element which you can use in your script. ; ; ; Stan Littlefield, February 17, 2005 [Revision 1] ;////////////////////////////////////////////////////////////////////////// IntControl(73,1,0,0,0) ;goto error handler gosub udfs delim = StrCat(@CRLF,"/////////////////////////////////////////////////",@CRLF) If ! IsInReg("InternetExplorer.Application") Display(2,"Cannot Continue","This Script Requires Internet Explorer") Exit Endif path = dirscript() lH=0 lI=0 lS=0 lT=0 lM=0 lD=0 :start dirchange(path) CFormat=`WWWDLGED,6.1` CCaption=`Analyze Web Links` CX=-01 CY=-01 CWidth=174 CHeight=165 CNumControls=011 CProcedure=`DEFAULT` CFont=`DEFAULT` CTextColor=`DEFAULT` CBackground=`"bk1.bmp",0|255|255` CConfig=0 C001=`105,053,036,036,PUSHBUTTON,DEFAULT,"Begin",1,1,32,"Microsoft Sans Serif|5632|70|34","0|0|0",DEFAULT` C002=`105,099,036,036,PUSHBUTTON,DEFAULT,"Quit",2,2,DEFAULT,"Microsoft Sans Serif|5632|70|34","0|0|0",DEFAULT` C003=`027,009,080,020,PUSHBUTTON,DEFAULT,"Sundance DataGuard",3,3,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C004=`115,009,036,024,PICTURE,DEFAULT,"Picture 1",DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,"sd.bmp"` C005=`015,049,066,012,CHECKBOX,lH,"Hyperlinks",1,5,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C006=`015,067,066,012,CHECKBOX,lI,"Inputs",1,6,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C007=`015,085,066,012,CHECKBOX,lT,"Table Data",1,7,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C008=`015,103,066,012,CHECKBOX,lS,"Selects",1,8,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C009=`011,035,078,012,STATICTEXT,DEFAULT,"Check Output Options",DEFAULT,9,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C010=`015,121,044,012,CHECKBOX,lM,"Images",1,10,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` C011=`015,139,050,012,CHECKBOX,lD,"Div/Span",1,11,DEFAULT,"Microsoft Sans Serif|6656|70|34","0|0|0",DEFAULT` B=Dialog("C") If B == 2 Then Exit If B == 3 display(2,"","Sundance_DataGuard") goto start Endif file = AskFileName("Select Saved HTML File", dirscript(), "HTML Files|*.htm;*.html|", "", 1) file1=StrCat(file,".txt") cLinks="" cLinks = StrCat(cLinks,'Winbatch code assumes: oIE = CreateObject("InternetExplorer.Application")',@CRLF,@CRLF) cLinks = StrCat(cLinks,"Output for HTML: %file%",@CRLF,@CRLF) oIE = CreateObject("InternetExplorer.Application") oIE.visible = @TRUE If FileExist(file) cLinks="" oIE.navigate(file) If ! ieReady() Then goto end BoxOpen("Please Wait...","Processing %file%") gosub morelinks FilePut( file1,cLinks ) BoxText("Output File Created %file1%") Timedelay(1) BoxShut() Endif :end oIE.Quit() oIE=0 Goto Start :Cancel Goto start :WBERRORHANDLER IntControl(73,1,0,0,0) ErrorProcessing(1,1,1) oIE=0 Exit :morelinks IF lH cHlinks = oIE.Document.Body.GetElementsByTagName("A") If cHlinks For z = 0 To cHlinks.length-1 BoxText("Hyperlink %z%") S = cHlinks.item(z) message("",S.Attributes.Count) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("A").Item(',z,")",@CRLF) If S.GetAttribute("innerHTML")<>"" Then cLinks= StrCat(cLinks," HTML:",S.innerHTML,@CRLF) If S.GetAttribute("innerText")<>"" Then cLinks= StrCat(cLinks," Text:",S.innerText,@CRLF) If S.GetAttribute("href")<>"" Then cLinks= StrCat(cLinks," Href:",S.href,@CRLF) Next Endif Endif If lI cHlinks = oIE.Document.Body.GetElementsByTagName("INPUT") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("Input %z%") S = cHlinks.item(z) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("INPUT").Item(',z,")",@CRLF) If S.GetAttribute("name")<>"" Then cLinks= StrCat(cLinks," Name:",S.name,@CRLF) If S.GetAttribute("id")<>"" Then cLinks= StrCat(cLinks," ID:",S.id,@CRLF) If S.GetAttribute("Value")<>"" Then cLinks= StrCat(cLinks," Value:",S.value,@CRLF) If S.type<>"" cLinks = StrCat(cLinks," Type:",S.type,@CRLF) If StrIndex( "RADIO|CHECKBOX",StrUpper( S.Type ),0,@FWDSCAN) Then cLinks = StrCat(cLinks," Checked:",S.checked,@CRLF) Endif Next Endif Endif If lS cHlinks = oIE.Document.Body.GetElementsByTagName("SELECT") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("Select %z%") S = cHlinks.item(z) nOpts = S.Options.length If nOpts For i = 0 To S.Options.length-1 cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("SELECT").Item(',z,")",@CRLF) If S.GetAttribute("name")<>"" Then cLinks= StrCat(cLinks," Name:",S.name,@CRLF) If S.GetAttribute("innerText")<>"" Then cLinks= StrCat(cLinks," Text:",S.name,@CRLF) cLinks = StrCat(cLinks,S.Options(i).innerText,@CRLF," Option Value %i%:",S.Options(i).Value,@CRLF) Next Else cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("SELECT").Item(',z,")",@CRLF," Name:",S.name,@CRLF," Value:",S.Value,@CRLF) Endif Next Endif Endif If lT cHlinks = oIE.Document.Body.GetElementsByTagName("TABLE") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("Table Data %z%") S = cHlinks.item(z) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("TABLE").Item(',z,")",@CRLF) If S.GetAttribute("name")<>"" Then cLinks = StrCat(cLinks," Name:",S.name,@CRLF) If S.GetAttribute("innerText")<>"" Then cLinks= StrCat(cLinks," Text:",S.innerText,@CRLF) If S.GetAttribute("innerHTML")<>"" Then cLinks= StrCat(cLinks," HTML:",S.innerHTML,@CRLF) Next Endif Endif If lM cHlinks = oIE.Document.Body.GetElementsByTagName("IMG") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("Image Data %z%") S = cHlinks.item(z) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("IMG").Item(',z,")"," Source:",S.src,@CRLF) Next Endif Endif If lD cHlinks = oIE.Document.Body.GetElementsByTagName("DIV") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("DIV Data %z%") S = cHlinks.item(z) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("DIV").Item(',z,")",@CRLF) If S.GetAttribute("name")<>"" Then cLinks= StrCat(cLinks," Name:",S.name,@CRLF) If S.GetAttribute("innerText")<>"" Then cLinks= StrCat(cLinks," Text:",S.innerText,@CRLF) If S.GetAttribute("value")<>"" Then cLinks= StrCat(cLinks," Value:",S.value,@CRLF) Next Endif cHlinks = oIE.Document.Body.GetElementsByTagName("SPAN") If cHlinks cLinks = StrCat(cLinks,delim) For z = 0 To cHlinks.length-1 BoxText("SPAN Data %z%") S = cHlinks.item(z) cLinks = StrCat(cLinks,'oIE.Document.Body.GetElementsByTagName("DIV").Item(',z,")",@CRLF) If S.GetAttribute("name")<>"" Then cLinks= StrCat(cLinks," Name:",S.name,@CRLF) If S.GetAttribute("innerText")<>"" Then cLinks= StrCat(cLinks," Text:",S.innerText,@CRLF) If S.GetAttribute("value")<>"" Then cLinks= StrCat(cLinks," Value:",S.value,@CRLF) Next Endif Endif Return :udfs #DefineFunction isInReg(cProg) Return( RegExistKey(@RegClasses,cProg) ) #EndFunction #DefineSubroutine ieready() IntControl(73,1,0,0,0) t = 0 While oIE.readystate != 4 t = t+1 display(.5,"Loading... Please Be patient... WebSite may be busy...","Attempt %t% on Page %page%") If t>30 Then Return(0) EndWhile t=0 While oIE.Document.readystate != "complete" t = t+1 display(.5,"Document is...",oIE.Document.readystate) If t>30 Then Return(0) EndWhile Return(1) :WBERRORHANDLER IntControl(73,1,0,0,0) ErrorProcessing(1,1,1) If ( VarType(oIE) &1536)==1536 Then oIE.Quit() oIE=0 Exit #EndSubroutine #DefineSubroutine ErrorProcessing(deleteIni,showerr,logfile) WbError = LastError() WbTextcode = WbError If WbError==1668||WbError==2669||WbError==3670 ; 1668 ; "Minor user-defined error" ; 2669 ; "Moderate user-defined error" ; 3670 ; "Severe user-defined error" WbError = ItemExtract(1,IntControl(34,-1,0,0,0),":") WbTextcode = -1 EndIf WbErrorString = IntControl(34,WbTextcode,0,0,0) WbErrorDateTime = TimeYmdHms() WbErrorFile = StrCat(DirWindows(0),"WWWBATCH.INI") If deleteIni FileDelete(WbErrorFile) IniWritePvt(WbErrorDateTime,"CurrentScript",WbErrorHandlerFile ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorValue" ,WbError ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorString" ,WbErrorString ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptLine" ,WbErrorHandlerLine ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptOffset" ,WbErrorHandlerOffset ,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarAssignment",WbErrorHandlerAssignment,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarInSegment" ,WbErrorInSegment,WbErrorFile) IniWritePvt("","","",WbErrorFile) Endif WbErrorMsgText = StrCat(WbErrorDateTime,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Current Script: ",WbErrorHandlerFile,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error# [",WbError,"]",@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error Text: ",wberrortextstring,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"[Extended Information] ",wberroradditionalinfo,@CRLF,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"On Line:",@CRLF,WbErrorHandlerLine,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Offset: ",WbErrorHandlerOffset,@CRLF) If (WbErrorHandlerAssignment>"") Then %WbErrorHandlerAssignment% = "UNKNOWN" WbErrorMsgText = StrCat(WbErrorMsgText,"Assignment/Variable: ",WbErrorHandlerAssignment,@CRLF) If (WbErrorInSegment>"") Then WbErrorMsgText = StrCat(WbErrorMsgText,"In UDF/UDS: ",WbErrorInSegment,@CRLF) If logfile cSep = StrCat(StrFill("=",50),@CRLF) cLogFile = StrCat(dirscript(),"log.err") If ! FileExist(cLogFile) Then FilePut(cLogFile,StrCat("Error Log",@CRLF,cSep)) FilePut(cLogFile,StrCat(FileGet(cLogFile),WbErrorMsgText,cSep)) Endif If showerr Then Message("wbErrorHandler",WbErrorMsgText) Return(1) #EndSubroutine Return
Article ID: W17178
File Created: 2007:07:03:14:28:36
Last Updated: 2007:07:03:14:28:36