Sign in to follow this  
Followers 0
dumbledor

Find unknown number in HTML

4 posts in this topic

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&nbsp;</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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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, '&nbsp;</b></td><td>na uro</td>', "") ; Now we take that cut line1 & cut it again this time wwe remove: &nbsp;</b></td><td>na uro</td>

MsgBox(4096,"",$text2)
Edited 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]

Share this post


Link to post
Share on other sites

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, '&nbsp;</b></td><td>na uro</td>', "") ; Now we take that cut line1 & cut it again this time wwe remove: &nbsp;</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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0