ihousden Posted March 29, 2011 Share Posted March 29, 2011 The answer may be out there already, but I could not find it. Here goes. Im doing a scrape of an html report and pulling off data that will be used to populate another system. Within the report, there are a variable number of elements I wish to scrape. The object names (objects being scraped from the report) are predictable "resdesc1", "resdesc2", and so on. If I scrape for an item that does not exist, a "0" is returned. Based on that, I wish to scrape the report object "resdesc1" and save it as array variable 1. If resdesc1 <> "0" then scrape "resdesc2 for array variable 2, and so on. Thus, building the array until a "0" is returned. I can successfully scrape the field using a fixed variable, but this does not work well for populating the new system (and I need to sort it). Here is how im doing it now. $resdesc1 = _IEFormElementGetObjByName ($oForm, "resdesc1") $resdesc2 = _IEFormElementGetObjByName ($oForm, "resdesc2") Any help appreciated. Link to comment Share on other sites More sharing options...
bogQ Posted March 29, 2011 Share Posted March 29, 2011 something like this shud work #include <Array.au3> Dim $avArray[1] $number = 0 While 1 $number += 1 $oName = _IEFormElementGetObjByName ($oForm, "resdesc"&$number) If @error Then ExitLoop _ArrayAdd($avArray, $oName) WEnd $avArray[0] = UBound($avArray)-1 _ArrayDisplay($avArray) TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
ihousden Posted March 29, 2011 Author Share Posted March 29, 2011 Thanks BogQ. Its sortof working. It did create an array with 15 rows (correct), but it did not populate the data into each row. And row 0 has a "15" (line count?) in it. Pic attached. I cant see any fault in the code though. Ideas? Link to comment Share on other sites More sharing options...
ihousden Posted March 29, 2011 Author Share Posted March 29, 2011 Did I not attach the pic? Crap, sorry. Link to comment Share on other sites More sharing options...
ihousden Posted March 29, 2011 Author Share Posted March 29, 2011 Console has this warning: --> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch I assumed it was from the loop hitting the "0" input. But im not sure. Cheers Link to comment Share on other sites More sharing options...
bogQ Posted March 29, 2011 Share Posted March 29, 2011 (edited) I did pos you a example, not full working code. You did not post your full code that can replicate problem, and i`m still not sure what is the needed end result that need to b in the array? I did put _ArrayAdd($avArray, $oName) because your $resdesc1 = _IEFormElementGetObjByName ($oForm, "resdesc1") So the result in array is equivalent to your variables at the moment, if you need some other data change the line to suit your needs or post the script and one more time explain what you need to b end result. Yes, 15 = resdesc-s Edited March 29, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
ihousden Posted March 29, 2011 Author Share Posted March 29, 2011 Quite true BogQ. Problem is that the page is on a closed intranet so you wont have access to the link. I have saved it as a an HTML complete page and attached. you can save it locally (both html file and folder of the same name have to be in the same dir). Then change the _IECreate path to point to the local html file. You should then be able to run the code against the page. The array should have the names of the connecting sites (in the resources section on the right of the page). Here is the code. expandcollapse popup; Includes: #include <IE.au3> #include <Array.au3> DIM $resname DIM $smode DIM $desc DIM $sdate DIM $edate DIM $DDLName DIM $DDLSelect DIM $StartHr DIM $StartMin DIM $EndHr DIM $EndMin DIM $Bridge DIM $Host DIM $SFT DIM $resdesc1 $oIE = _IECreate("http://resourcescheduler.com/resourcescheduler/scheddtl.asp?ID=-1999901972") _IELoadWait ($oIE) Sleep(300) $oForm = _IEFormGetObjByName ($oIE, "frmDtl") $resname = _IEFormElementGetObjByName ($oForm, "Desc") $DDLName = "schedColor" DDLQuery() $smode = $DDLSelect $desc = _IEFormElementGetObjByName ($oForm, "ExtDesc") $sdate = _IEFormElementGetObjByName ($oForm, "schedDate") $edate = _IEFormElementGetObjByName ($oForm, "schedEndDate") $DDLName = "StartHr" DDLQuery() $StartHr = $DDLSelect $DDLName = "StartMin" DDLQuery() $StartMin = $DDLSelect $DDLName = "EndHr" DDLQuery() $EndHr = $DDLSelect $DDLName = "EndMin" DDLQuery() $EndMin = $DDLSelect $DDLName = "Udf5" DDLQuery() $Bridge = $DDLSelect $Host = _IEFormElementGetObjByName ($oForm, "Udf6") $SFT = _IEFormElementGetObjByName ($oForm, "Udf11") Dim $avArray[1] $number = 0 While 1 $number = $number + 1 $oName = _IEFormElementGetObjByName ($oForm, "resdesc"&$number) If @error Then ExitLoop _ArrayAdd($avArray, $oName) WEnd $avArray[0] = UBound($avArray)-1 _ArrayDisplay($avArray) Func DDLQuery() $oSelect = _IEGetObjByName($oIE, $DDLName) $colChildren = _IETagNameGetCollection($oSelect, "Option") For $oChild In $colChildren $sValue = $oChild.value $sText = $oChild.innerText $vSelected = $oChild.selected if $oChild.selected = "True" Then $DDLSelect = $oChild.innerText EndIf ;ConsoleWrite("Debug: Value = " & $sValue & "; Text = " & $sText & "; Selected = " & $vSelected & @LF) Next EndFunc Thanks for the helpReservation details.zip Link to comment Share on other sites More sharing options...
bogQ Posted March 29, 2011 Share Posted March 29, 2011 If you mean names like "1. ARC/CGH: CGH ICU-2 (+bk w/owner) " change line to $oName = _IEFormElementGetValue(_IEFormElementGetObjByName ($oForm, "resdesc"&$number)) as for scite error '--> IE.au3 V2.4-0 Warning from function _IEFormElementGetObjByName, $_IEStatus_NoMatch', thats normal in this case because i expect the error so that i can brake loop instead all that dimming use one line DIM $resname,$smode,$desc,$sdate,$edate,$DDLName,$DDLSelect,$StartHr,$StartMin,$EndHr,$EndMin,$Bridge,$Host,$SFT,$resdesc1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
ihousden Posted March 29, 2011 Author Share Posted March 29, 2011 Wow, that was fast. Thats exactly what I was looking for. Thanks very much bogQ! That was from our Video Conference booking system. Now I have to take this data and populate a conference reservation on our VC Bridge. If I get this working, it will save alot of manual entry. Thanks for your patience too. It was a hard thing to try and describe without posting the page it was referencing. I'll do that first next time. Cheers! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now