dumbledor Posted January 2, 2008 Share Posted January 2, 2008 I am extracting html source code from a web page and i need to find variable and put it out in msgbox. Ok here is what i have done $file = FileOpen("e:\test.html", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $html = FileRead($file) $Value_1=StringRegExp($html,"Les:",1) FileClose($file) MsgBox(0,"",$Value_1[0]) This is part of test.html: <td>Les:</td><td align="right"><b>1000 </b></td><td>na uro</td> So i need to get out number 1000 but this is variable and it changes. So what code can i use to get variable from that code. Thanks for help, hint, code and guidence you can give me. I readed forum, tested few parts of coding but i wasn t succesful. Link to comment Share on other sites More sharing options...
goldenix Posted January 2, 2008 Share Posted January 2, 2008 (edited) i need to get out number 1000 but this is variable and it changes. So what code can i use to get variable from that code. Thanks for help, hint, code and guidence you can give me. I readed forum, tested few parts of coding but i wasn t succesful. Dunno Maybe there is more smarter way to do this: hire is 1 simple way using StringReplace, basically we cut out this variable: #include <file.au3> #include <Array.au3> ; File cant be Empty, there is always atleast 1 line ; $aRecords[0] - First array line, Starting count from [0] shows the nr. of the lines in the file ; $aRecords[1] - second line of the array shows the contents of the first line, [2] second line etc... Dim $aRecords,$y If Not _FileReadToArray("test.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $text = StringReplace($aRecords[3], '<td>Les:</td><td align="right"><b>', "") ; $aRecords[3] is the line nr. we cut this: <td>Les:</td><td align="right"><b> $text2 = StringReplace($text, ' </b></td><td>na uro</td>', "") ; Now we take that cut line1 & cut it again this time wwe remove: </b></td><td>na uro</td> MsgBox(4096,"",$text2) Edited January 2, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
dumbledor Posted January 2, 2008 Author Share Posted January 2, 2008 Dunno Maybe there is more smarter way to do this: hire is 1 simple way using StringReplace, basically we cut out this variable: #include <file.au3> #include <Array.au3> ; File cant be Empty, there is always atleast 1 line ; $aRecords[0] - First array line, Starting count from [0] shows the nr. of the lines in the file ; $aRecords[1] - second line of the array shows the contents of the first line, [2] second line etc... Dim $aRecords,$y If Not _FileReadToArray("test.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $text = StringReplace($aRecords[3], '<td>Les:</td><td align="right"><b>', "") ; $aRecords[3] is the line nr. we cut this: <td>Les:</td><td align="right"><b> $text2 = StringReplace($text, ' </b></td><td>na uro</td>', "") ; Now we take that cut line1 & cut it again this time wwe remove: </b></td><td>na uro</td> MsgBox(4096,"",$text2) Thank you. I tried it and it works, now i must just put it in whole code to make it work. If some one has another solution i would like to hear it, becouse i am still learning and want to use different approaches to my problems so i can see what works best. Thanks again. Link to comment Share on other sites More sharing options...
DaleHohm Posted January 2, 2008 Share Posted January 2, 2008 If you want a different kind of solution, look at _IETableWriteToArray in the helpfile. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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