RuuddeRuijter Posted March 10, 2017 Posted March 10, 2017 Hello, I am new to autoit and I want to make an application that can read certain text. At the moment I got this to get the text, but it returns a lot of stuff And I only want to get this info: document.getElementById('amount_3454169'). That number can be different. IDK how to grab that too. Spoiler $_innertext : Product Aantal Groothandel Veiling Voordeel Totaalprijs Voetbal 152 € 12,42 € 12,08 3 % € 1.835,70 document.getElementById('price_3454169').value = 190950-7380; document.getElementById('amount_3454169').value = 152; document.getElementById('marketprice_3454169').value = 1242; Luxe zeep 775 € 2,45 € 2,37 3 % € 1.835,70 document.getElementById('price_3454171').value = 190950-7380; document.getElementById('amount_3454171').value = 775; document.getElementById('marketprice_3454171').value = 245; Tennisracket 40 € 46,57 € 45,89 1 % € 1.835,70 document.getElementById('price_3454170').value = 190950-7380; document.getElementById('amount_3454170').value = 40; document.getElementById('marketprice_3454170').value = 4657; Tennisracket 38 € 46,57 € 36,84 21 % € 1.399,95 document.getElementById('price_3454157').value = 180900-40905; document.getElementById('amount_3454157').value = 38; document.getElementById('marketprice_3454157').value = 4657; Wijn 1343 € 1,34 € 1,04 22 % € 1.399,95 document.getElementById('price_3454156').value = 180900-40905; document.getElementById('amount_3454156').value = 1343; document.getElementById('marketprice_3454156').value = 134; Tulpen 2168 € 0,83 € 0,80 4 % € 1.735,20 document.getElementById('price_3454172').value = 180900-7380; document.getElementById('amount_3454172').value = 2168; document.getElementById('marketprice_3454172').value = 83; Bier 1328 € 1,28 € 1,11 13 % € 1.468,65 document.getElementById('price_3454160').value = 170850-23985; document.getElementById('amount_3454160').value = 1328; document.getElementById('marketprice_3454160').value = 128; Tulpen 1927 € 0,83 € 0,66 20 % € 1.262,40 document.getElementById('price_3454159').value = 160800-34560; document.getElementById('amount_3454159').value = 1927; document.getElementById('marketprice_3454159').value = 83; Wijn 1194 € 1,34 € 1,06 21 % € 1.262,40 document.getElementById('price_3454158').value = 160800-34560; document.getElementById('amount_3454158').value = 1194; document.getElementById('marketprice_3454158').value = 134; Luxe zeep 612 € 2,45 € 2,46 0 % € 1.507,50 document.getElementById('price_3454173').value = 150750-0; document.getElementById('amount_3454173').value = 612; document.getElementById('marketprice_3454173').value = 245; This is the code I am using for this: Func getPercentage() $oForms = _IEFormGetCollection ( $oIE2 ) For $oForm In $oForms $_innertext = $oForm.innertext ConsoleWrite ( "$_innertext : " & $_innertext & @CRLF ) Next #cs $getPercentage = _IEPropertyGet($oIE2, "right tdAuctionRound") ConsoleWrite($getPercentage) #ce EndFunc
mikell Posted March 10, 2017 Posted March 10, 2017 2 hours ago, RuuddeRuijter said: And I only want to get this info: document.getElementById('amount_3454169'). That number can be different. IDK how to grab that too. Please specify. Do you want to get the first ('amount_3454169') info only, or all the 'amount' infos in the text ?
RuuddeRuijter Posted March 11, 2017 Author Posted March 11, 2017 (edited) 22 hours ago, Subz said: Can you post a url or copy of the source? Added the image as attachment The percents in the red boxes are the ones I want to get 21 hours ago, mikell said: Please specify. Do you want to get the first ('amount_3454169') info only, or all the 'amount' infos in the text ? All the amount, but maybe doing it with a loop, because I need to know if it's more than 33%, if it is then it has to press on the button next to it. Edited March 11, 2017 by RuuddeRuijter
Subz Posted March 11, 2017 Posted March 11, 2017 In Chrome or IE can you right click the table and select "inspect" over the table and copy the source code up for this only?
RuuddeRuijter Posted March 11, 2017 Author Posted March 11, 2017 1 minute ago, Subz said: In Chrome or IE can you right click the table and select "inspect" over the table and copy the source code up for this only? This is what I found: <td class="right tdAuctionRound" id="showmarketprice_3454789"><strong>20 %</strong></td>
Subz Posted March 11, 2017 Posted March 11, 2017 Can you right click the <table> element or the <form> element above the <td> within the Element Inspector and select : Copy » Copy Element.
RuuddeRuijter Posted March 11, 2017 Author Posted March 11, 2017 (edited) 12 minutes ago, Subz said: Can you right click the <table> element or the <form> element above the <td> within the Element Inspector and select : Copy » Copy Element. Okay, this is what I get: Spoiler <table id="tblMarket" cellspacing="0" cellpadding="2"> <thead> <tr><th> </th> <th>Product </th> <th class="right">Aantal </th> <th class="right">Groothandel </th> <th class="right"> Veiling </th> <th class="right">Voordeel </th> <th class="right">Totaalprijs </th> <th> </th> </tr></thead> <input type="hidden" id="price_3454811" value="143430"> <input type="hidden" id="amount_3454811" value="2048"> <input type="hidden" id="marketprice_3454811" value="83"> <tbody><tr> <td> <img src="/Images/products/23_small.gif"> </td> <td>Tulpen </td> <td class="right">2048 </td> <td class="right">€ 0,83 </td> <td class="right" id="showproductprice_3454811" nowrap="">€ 0,70</td> <td class="right tdAuctionRound" id="showmarketprice_3454811"><strong>16 %</strong></td> <td class="right" id="showprice_3454811" style="font-weight:bold;">€ 1.434,30</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454811" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454811; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454811').value = 170850-23760;</script> <script type="text/javascript"> document.getElementById('amount_3454811').value = 2048;</script> <script type="text/javascript"> document.getElementById('marketprice_3454811').value = 83;</script> <input type="hidden" id="price_3454809" value="125100"> <input type="hidden" id="amount_3454809" value="653"> <input type="hidden" id="marketprice_3454809" value="245"> <tr> <td> <img src="/Images/products/53_small.gif"> </td> <td>Luxe zeep </td> <td class="right">653 </td> <td class="right">€ 2,45 </td> <td class="right" id="showproductprice_3454809" nowrap="">€ 1,92</td> <td class="right tdAuctionRound" id="showmarketprice_3454809"><strong>22 %</strong></td> <td class="right" id="showprice_3454809" style="font-weight:bold;">€ 1.251,00</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454809" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454809; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454809').value = 160800-32040;</script> <script type="text/javascript"> document.getElementById('amount_3454809').value = 653;</script> <script type="text/javascript"> document.getElementById('marketprice_3454809').value = 245;</script> <input type="hidden" id="price_3454807" value="101310"> <input type="hidden" id="amount_3454807" value="571"> <input type="hidden" id="marketprice_3454807" value="245"> <tr> <td> <img src="/Images/products/53_small.gif"> </td> <td>Luxe zeep </td> <td class="right">571 </td> <td class="right">€ 2,45 </td> <td class="right" id="showproductprice_3454807" nowrap="">€ 1,77</td> <td class="right tdAuctionRound" id="showmarketprice_3454807"><strong>28 %</strong></td> <td class="right" id="showprice_3454807" style="font-weight:bold;">€ 1.013,10</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454807" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454807; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454807').value = 140700-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454807').value = 571;</script> <script type="text/javascript"> document.getElementById('marketprice_3454807').value = 245;</script> <input type="hidden" id="price_3454803" value="91260"> <input type="hidden" id="amount_3454803" value="1326"> <input type="hidden" id="marketprice_3454803" value="98"> <tr> <td> <img src="/Images/products/24_small.gif"> </td> <td>Amarylissen </td> <td class="right">1326 </td> <td class="right">€ 0,98 </td> <td class="right" id="showproductprice_3454803" nowrap="">€ 0,69</td> <td class="right tdAuctionRound" id="showmarketprice_3454803"><strong>30 %</strong></td> <td class="right" id="showprice_3454803" style="font-weight:bold;">€ 912,60</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454803" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454803; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454803').value = 130650-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454803').value = 1326;</script> <script type="text/javascript"> document.getElementById('marketprice_3454803').value = 98;</script> <input type="hidden" id="price_3454804" value="91260"> <input type="hidden" id="amount_3454804" value="63"> <input type="hidden" id="marketprice_3454804" value="2062"> <tr> <td> <img src="/Images/products/52_small.gif"> </td> <td>Parfum </td> <td class="right">63 </td> <td class="right">€ 20,62 </td> <td class="right" id="showproductprice_3454804" nowrap="">€ 14,49</td> <td class="right tdAuctionRound" id="showmarketprice_3454804"><strong>30 %</strong></td> <td class="right" id="showprice_3454804" style="font-weight:bold;">€ 912,60</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454804" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454804; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454804').value = 130650-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454804').value = 63;</script> <script type="text/javascript"> document.getElementById('marketprice_3454804').value = 2062;</script> <input type="hidden" id="price_3454808" value="94950"> <input type="hidden" id="amount_3454808" value="1566"> <input type="hidden" id="marketprice_3454808" value="83"> <tr> <td> <img src="/Images/products/23_small.gif"> </td> <td>Tulpen </td> <td class="right">1566 </td> <td class="right">€ 0,83 </td> <td class="right" id="showproductprice_3454808" nowrap="">€ 0,61</td> <td class="right tdAuctionRound" id="showmarketprice_3454808"><strong>27 %</strong></td> <td class="right" id="showprice_3454808" style="font-weight:bold;">€ 949,50</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454808" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454808; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454808').value = 130650-32040;</script> <script type="text/javascript"> document.getElementById('amount_3454808').value = 1566;</script> <script type="text/javascript"> document.getElementById('marketprice_3454808').value = 83;</script> <input type="hidden" id="price_3454802" value="91260"> <input type="hidden" id="amount_3454802" value="240"> <input type="hidden" id="marketprice_3454802" value="540"> <tr> <td> <img src="/Images/products/54_small.gif"> </td> <td>Dagcrème </td> <td class="right">240 </td> <td class="right">€ 5,40 </td> <td class="right" id="showproductprice_3454802" nowrap="">€ 3,80</td> <td class="right tdAuctionRound" id="showmarketprice_3454802"><strong>30 %</strong></td> <td class="right" id="showprice_3454802" style="font-weight:bold;">€ 912,60</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454802" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454802; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454802').value = 130650-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454802').value = 240;</script> <script type="text/javascript"> document.getElementById('marketprice_3454802').value = 540;</script> <input type="hidden" id="price_3454805" value="71160"> <input type="hidden" id="amount_3454805" value="23"> <input type="hidden" id="marketprice_3454805" value="4657"> <tr> <td> <img src="/Images/products/7_small.gif"> </td> <td>Tennisracket </td> <td class="right">23 </td> <td class="right">€ 46,57 </td> <td class="right" id="showproductprice_3454805" nowrap="">€ 30,94</td> <td class="right tdAuctionRound" id="showmarketprice_3454805"><strong>34 %</strong></td> <td class="right" id="showprice_3454805" style="font-weight:bold;">€ 711,60</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454805" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454805; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454805').value = 110550-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454805').value = 23;</script> <script type="text/javascript"> document.getElementById('marketprice_3454805').value = 4657;</script> <input type="hidden" id="price_3454810" value="74850"> <input type="hidden" id="amount_3454810" value="982"> <input type="hidden" id="marketprice_3454810" value="112"> <tr> <td> <img src="/Images/products/2_small.gif"> </td> <td>Limonade </td> <td class="right">982 </td> <td class="right">€ 1,12 </td> <td class="right" id="showproductprice_3454810" nowrap="">€ 0,76</td> <td class="right tdAuctionRound" id="showmarketprice_3454810"><strong>32 %</strong></td> <td class="right" id="showprice_3454810" style="font-weight:bold;">€ 748,50</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454810" value="Kopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454810; document.submitForm.submit();}{return false;}"> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454810').value = 110550-32040;</script> <script type="text/javascript"> document.getElementById('amount_3454810').value = 982;</script> <script type="text/javascript"> document.getElementById('marketprice_3454810').value = 112;</script> <input type="hidden" id="price_3454806" value="71160"> <input type="hidden" id="amount_3454806" value="448"> <input type="hidden" id="marketprice_3454806" value="245"> <tr> <td> <img src="/Images/products/53_small.gif"> </td> <td>Luxe zeep </td> <td class="right">448 </td> <td class="right">€ 2,45 </td> <td class="right" id="showproductprice_3454806" nowrap="">€ 1,60</td> <td class="right tdAuctionRound" id="showmarketprice_3454806"><img src="/Images/failed.gif"></td> <td class="right" id="showprice_3454806" style="font-weight:bold;">€ 714,60</td> <td class="center" bgcolor="white"> <input type="button" id="buybutton_3454806" value="Verlopen" class="button" onclick="if(confirm('Wil je deze producten kopen?')){document.submitForm.BuyAuctionNr.value=3454806; document.submitForm.submit();}{return false;}" disabled=""> </td> </tr> <script type="text/javascript"> document.getElementById('price_3454806').value = 110550-35730;</script> <script type="text/javascript"> document.getElementById('amount_3454806').value = 448;</script> <script type="text/javascript"> document.getElementById('marketprice_3454806').value = 245;</script> </tbody></table> This is what I tried: Func getPercentage() $obj = _IEGetObjById($oIE2,"tblMarket") For $tag in $obj $class_value = $tag.className("right tdAuctionRound") ConsoleWrite($class_value) Next EndFunc But it gives this error: Spoiler --> COM Error encountered in Get rowthing.au3 (37) : ----> $IEComErrorNumber = 0x80020003 (-2147352573) ----> $IEComErrorWinDescription = Kan lid niet vinden. ----> $IEComErrorDescription = ----> $IEComErrorSource = ----> $IEComErrorHelpFile = ----> $IEComErrorHelpContext = ----> $IEComErrorLastDllError = 0 ----> $IEComErrorRetcode = 0x00000000 Edited March 11, 2017 by RuuddeRuijter
Subz Posted March 12, 2017 Posted March 12, 2017 Here are two examples: 1. Get the entire table as an array #include <Array.au3> #include <IE.au3> Local $oIE = _IECreate("Filename.html", 1) _IELoadWait($oIE) Local $aTable[0][6], $sTable Local $oTableCells Local $oTableRows = _IETagNameGetCollection($oIE, "tr") For $oTableRow In $oTableRows $sTable = "" $oTableCells = _IETagNameGetCollection($oTableRow, "td") For $i = 0 To $oTableCells.length If IsObj($oTableCells($i)) Then If StringStripWS($oTableCells($i).InnerText, 8) = "" Then If StringInStr($oTableCells($i).InnerHtml, "/Images/failed.gif") Then $sTable &= "|" ContinueLoop EndIf If $i = $oTableCells.length - 2 Then $sTable &= _HTMLClean($oTableCells($i).InnerText) Else $sTable &= _HTMLClean($oTableCells($i).InnerText) & "|" EndIf EndIf Next _ArrayAdd($aTable, $sTable) Next _ArrayDisplay($aTable) 2. Get just the document.getElementById into an Array #include <Array.au3> #include <IE.au3> #include <String.au3> Local $aScript[0][3], $sScript, $aString Local $oScripts = _IETagNameGetCollection($oIE, "script") For $oScript In $oScripts If StringInStr($oScript.innerhtml, "document.getElementById") = - 1 Then ContinueLoop If StringInStr($oScript.innerhtml, "document.getElementById('price_") Then $sScript = "" If StringInStr($oScript.innerhtml, "document.getElementById('marketprice_") Then $aString = _StringBetween($oScript.innerhtml, ".value = ", ";") If IsArray($aString) Then $sScript &= $aString[0] _ArrayAdd($aScript, $sScript) Else $aString = _StringBetween($oScript.innerhtml, ".value = ", ";") If IsArray($aString) Then $sScript &= $aString[0] & "|" EndIf Next _ArrayDisplay($aScript)
RuuddeRuijter Posted March 12, 2017 Author Posted March 12, 2017 21 hours ago, Subz said: Here are two examples: 1. Get the entire table as an array #include <Array.au3> #include <IE.au3> Local $oIE = _IECreate("Filename.html", 1) _IELoadWait($oIE) Local $aTable[0][6], $sTable Local $oTableCells Local $oTableRows = _IETagNameGetCollection($oIE, "tr") For $oTableRow In $oTableRows $sTable = "" $oTableCells = _IETagNameGetCollection($oTableRow, "td") For $i = 0 To $oTableCells.length If IsObj($oTableCells($i)) Then If StringStripWS($oTableCells($i).InnerText, 8) = "" Then If StringInStr($oTableCells($i).InnerHtml, "/Images/failed.gif") Then $sTable &= "|" ContinueLoop EndIf If $i = $oTableCells.length - 2 Then $sTable &= _HTMLClean($oTableCells($i).InnerText) Else $sTable &= _HTMLClean($oTableCells($i).InnerText) & "|" EndIf EndIf Next _ArrayAdd($aTable, $sTable) Next _ArrayDisplay($aTable) 2. Get just the document.getElementById into an Array #include <Array.au3> #include <IE.au3> #include <String.au3> Local $aScript[0][3], $sScript, $aString Local $oScripts = _IETagNameGetCollection($oIE, "script") For $oScript In $oScripts If StringInStr($oScript.innerhtml, "document.getElementById") = - 1 Then ContinueLoop If StringInStr($oScript.innerhtml, "document.getElementById('price_") Then $sScript = "" If StringInStr($oScript.innerhtml, "document.getElementById('marketprice_") Then $aString = _StringBetween($oScript.innerhtml, ".value = ", ";") If IsArray($aString) Then $sScript &= $aString[0] _ArrayAdd($aScript, $sScript) Else $aString = _StringBetween($oScript.innerhtml, ".value = ", ";") If IsArray($aString) Then $sScript &= $aString[0] & "|" EndIf Next _ArrayDisplay($aScript) Thanks for you help. This got me some info, but not the one I needed. I probably informed you wrong. This is what I wanted to get: Spoiler <td class="right tdAuctionRound" id="showmarketprice_3454811"><strong>16 %</strong></td> and then the 16% between the strong tags But I don't need this anymore, as it was a temporary game that is over now Thanks for the help though, I really appreciate it.
Subz Posted March 12, 2017 Posted March 12, 2017 Actually the first option included the entire table including the market price (column 4) of the Array returned
RuuddeRuijter Posted March 12, 2017 Author Posted March 12, 2017 24 minutes ago, Subz said: Actually the first option included the entire table including the market price (column 4) of the Array returned Oh, sorry I didn't try the first option at all, Thanks for this!
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