Dude Posted December 12, 2007 Posted December 12, 2007 (edited) Hello,i have an HTML File that looks like this<input type="hidden" name="vote_average" id="edit-vote-average" value="97.778" />and<div id="fivestar-summary-71" class="description">Durchschnitt: 4.9 (14491 votes)</div>Now i want to open this html file, and want to filter the bold values.- value="97.778"- Durchschnitt: 4.9 (14491 votes)Can anyone help me with that ? I want to read out this, compare, to to something if an value is in- or decreasing Edited December 12, 2007 by Dude
Nahuel Posted December 12, 2007 Posted December 12, 2007 Try this: $html_1='<input type="hidden" name="vote_average" id="edit-vote-average" value="97.778" />' & @CR & _ '<div id="fivestar-summary-71" class="description">Durchschnitt: 4.9 (14491 votes)</div>' $Value_1=StringRegExp($html_1,'id="edit-vote-average" value="(.*?)"',1) $Value_2=StringRegExp($html_1,'Durchschnitt: (.*?)\((.*?) votes\)\</',1) MsgBox(0,"",$Value_1[0]) MsgBox(0,"",$Value_2[1]);Note:$Value_2[0] returns 4.9, in case you need that value too.
Dude Posted December 12, 2007 Author Posted December 12, 2007 I now have the following script: InetGet("http://www.xxxxx.de/fivestar/vote/node/71/20", "e:\test.html", 1) $file = FileOpen("e:\test.html", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $Value_1=StringRegExp($line,'id="edit-vote-average" value="(.*?)"',1) $Value_2=StringRegExp($line,'Durchschnitt: (.*?)\((.*?) votes\)\</',1) Wend FileClose($file) MsgBox(0,"",$Value_1[0]) MsgBox(0,"",$Value_2[1]);Note:$Value_2[0] returns 4.9, in case you need that value too. But now i get the following error: "subscript used with non-array variable"
Nahuel Posted December 12, 2007 Posted December 12, 2007 Well this is very wrong: While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $Value_1=StringRegExp($line,'id="edit-vote-average" value="(.*?)"',1) $Value_2=StringRegExp($line,'Durchschnitt: (.*?)\((.*?) votes\)\</',1) Wend the testing string is not in every line, I suppose. Besides, remember that the values of $Value_1 and $Value_2 will be overwritten every loop and the last line of your file doesn't have the lines you want, so StringRegExp doesn't return anything! Just read the whole file. No loop: $html = FileRead($file) $Value_1=StringRegExp($html,'id="edit-vote-average" value="(.*?)"',1) $Value_2=StringRegExp($html,'Durchschnitt: (.*?)\((.*?) votes\)\</',1)
Dude Posted December 12, 2007 Author Posted December 12, 2007 Ok...now it works perfect. Thanks a lot
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