Every time i've done web page scraping in the past, i feel like i "get lucky" when my program is finally able to extract the data that i'm targeting. So far i was only able to get "partially lucky" with this project. My program can currently grab one set of values, but i'm having a hard time grabbing a (nearly identical) 2nd set of values from the web interface.
Here is a snippet of the relevant parts of my program:
Code: Select all
;(* Initialize IExplorer COM Object *)
wb := IEGet("Operator View - IRIS081101") ;(* Create pointer to IE window *)
wb.Visible := True ;(* Unhide IE window *)
;(* ++===============================================================================================================================++ *)
;(* || Grab Data from Operator Web Interface || *)
;(* ++===============================================================================================================================++ *)
;(* *)
;(* Machine Counts -------------------------------------------------------------------------------------------------------------------- *)
;(* Batches *) ;(* *)
iBatchesExpected := wb.document.all.CR_Exp_Batches.Value ;(* Pull Expected Batches # *)
iCurrentBatchNum := wb.document.all.CR_Current_Batches.Value
;(* ++===============================================================================================================================++ *)
;(* || Functions || *)
;(* ++===============================================================================================================================++ *)
;(* *)
;(* Retrieve Internet Explorer Pointer ----------------------------------------------------------------------------------------------- *)
IEGet(Name="") ;(* *)
{ ;(* *)
IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame ;(* *)
Name := ( Name="New Tab - Windows Internet Explorer" ) ? "about:Tabs" ;(* *)
: RegExReplace( Name, " - (Windows|Microsoft) Internet Explorer" ) ;(* *)
For wb in ComObjCreate( "Shell.Application" ).Windows ;(* *)
If ( wb.LocationName = Name ) && InStr( wb.FullName, "iexplore.exe" ) ;(* *)
Return wb ;(* Return pointer to IE window *)
} ;(* *)
;(* ----------------------------------------------------------------------------------------------------------------------------------- *)
The iCurrentBatchNum value however comes through as "(Object)" when viewed in the Variable List window of SciTE editor <-- I should be retrieving a value in this case.
Oddly, these two elements share nearly identical code (from what i can tell) in the "DOM Explorer" window after performing an Inspect Element on each:
Expected Batches element Code:
Code: Select all
<INPUT class=placeholder id=CR_Exp_Batches style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 16px; CURSOR: auto; HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; WIDTH: 110px; BORDER-BOTTOM-WIDTH: 0px; FONT-WEIGHT: bold; COLOR: black; TEXT-ALIGN: right; PADDING-RIGHT: 10px; BORDER-TOP-WIDTH: 0px; BACKGROUND-COLOR: transparent" contentEditable=false value="Project ended." datype="Value" operatorviewname="testing">
Code: Select all
<TD class=datb0_GridStyle style="FONT-SIZE: 16px; WIDTH: 121px; PADDING-BOTTOM: 0px; TEXT-ALIGN: right; PADDING-TOP: 0px" cellStyle="0">
<DIV class=custom contentEditable=false dahtml="custom"><INPUT id=CR_Exp_Batches class=placeholder contentEditable=false style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 16px; HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; WIDTH: 110px; BORDER-BOTTOM-WIDTH: 0px; FONT-WEIGHT: bold; COLOR: black; TEXT-ALIGN: right; PADDING-RIGHT: 10px; BORDER-TOP-WIDTH: 0px; BACKGROUND-COLOR: transparent" value='{Flowcharts("Controls").Variables.CS_Exp_Batches:F0}' datype="Value"></DIV></TD>
Code: Select all
<INPUT class=placeholder id=CR_Current_Batches style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 16px; CURSOR: auto; HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; WIDTH: 110px; BORDER-BOTTOM-WIDTH: 0px; FONT-WEIGHT: bold; COLOR: blue; TEXT-ALIGN: right; PADDING-RIGHT: 10px; BORDER-TOP-WIDTH: 0px; BACKGROUND-COLOR: transparent" contentEditable=false value="Project ended." datype="Value" operatorviewname="testing">
Code: Select all
<TD class=datb0_GridStyle style="FONT-SIZE: 16px; WIDTH: 121px; PADDING-BOTTOM: 0px; TEXT-ALIGN: right; PADDING-TOP: 0px" cellStyle="1">
<DIV class=custom contentEditable=false dahtml="custom"><INPUT id=CR_Current_Batches class=placeholder contentEditable=false style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 16px; HEIGHT: 21px; BORDER-RIGHT-WIDTH: 0px; WIDTH: 110px; BORDER-BOTTOM-WIDTH: 0px; FONT-WEIGHT: bold; COLOR: blue; TEXT-ALIGN: right; PADDING-RIGHT: 10px; BORDER-TOP-WIDTH: 0px; BACKGROUND-COLOR: transparent" value='{(PR_Data.Fields("CR_Current_Batch").Value + 1):F0}' datype="Value"></DIV></TD>
When disconnected from the machine, these two fields are populated with a "Project ended." text string. This is the output i'm seeing stored in the "iExpectedBatches" variable, but the "iCurrentBatchNum" contains "(Object)" - I would expect both references would return the same value since both fields contain "Project ended." on the interface when offline.
Any help is appreciated!
(I would post the page source but it was way over the character limit for the post)