jacob_1998_1999 Posted October 8, 2008 Share Posted October 8, 2008 (edited) I'm trying to get the values out of these fields that I will be pulling from source every 20 seconds. I'll most likely end up using the various variables in a GUI or just standard MsgBox's queried by shortcut keys. $('user_group_size').innerHTML = "1489"; $('user_cash').innerHTML = "$198,519,293"; $('user_health').innerHTML = "323"; $('user_max_health').innerHTML = "323"; $('user_energy').innerHTML = "20"; $('user_max_energy').innerHTML = "120"; $('user_stamina').innerHTML = "12"; $('user_max_stamina').innerHTML = "15"; $('user_experience').innerHTML = "142006"; $('exp_for_next_level').innerHTML = "142507"; $('user_level').innerHTML = "150"; I'd like to put them into variables such as: $user_group_size = "1489" $user_cash = "$198,519,293" $user_health = "323" $user_max_health = "323" $user_energy = "20" $user_max_energy = "120" $user_stamina = "12" $user_max_stamina = "15" $user_experience = "142006" $exp_for_next_level = "142507" $user_level = "150" Any guidance would be much appreciated. *Edited to add values to the variables.. to clear up any doubts. Edit to include below: Could I possibly just get enough help to search for this " $('user_health').innerHTML = "323"; " (I can't reg stringinstr because of the ' and " quotes..) I would like to get the number so that I can run it against a If $user_health < 100 Then Blah(). I'm just stuck as to how to get about the quotes.. Once again.. Any help would be awesome. expandcollapse popup#include <IE.Au3> #include <inet.au3> $job_url = "http://" ;~ $oIE = _IECreate ("about:blank",0,1,1,0) ;~ _IELoadWait($oIE,1000) ;~ _IENavigate ($oIE, $job_url) ;~ _IELoadWait($oIE,1000) ;~ $sHTML = _IEDocReadHTML ($oIE) ;~ $UserHealthStringA = "user_health" ;~ $UserHealthStringB = '= "' ;MsgBox(0,"",StringInStr($sHTML, $UserHealthStringA)) ;$user_health = StringRegExp($sHTML,'innerHTML\s=\s"(.*?)"',1) ;~;MsgBox(0,"",_IEPropertyGet ($oIE, "body")) ;~ $user_group_size = "" ;~ $user_cash = "" ;~ $user_health = "" ;~ $user_max_health = "" ;~ $user_energy = "" ;~ $user_max_energy = "" ;~ $user_stamina = "" ;~ $user_max_stamina = "" ;~ $user_experience = "" ;~ $exp_for_next_level = "" ;~ $user_level = "" ;~ $Blah = 'Joes dat'"a said Beer!""' ConsoleWrite(_GetName()) Func _GetName() HttpSetProxy(0) Local $sSource = _INetGetSource($job_url) Local $sRetName = StringRegExpReplace($sSource, _ '.innerHTML\s=\s"(.*?)"','\1 \2 \3 \4 \5 \6') msgbox(1,"", $sRetName) EndFunc;==> _GetName I have tried.. I just do not know where to go to do this myself. Edited October 9, 2008 by jacob_1998_1999 Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted October 9, 2008 Author Share Posted October 9, 2008 $('\w+').innerHTML\s=\s"\d+"; or.. something like $('(.*?)').innerHTML\s=\s"(.*?)"; $Variable = $('(.*?)').innerHTML\s=\s".*?"; $Val = $('.*?').innerHTML\s=\s"(.*?)"; Is there a way to get around the quote issue? I've tried searching. (and is my syntax correct?) I know that I can get between the ' quote by using.. if($var =~ m/'(.*)'/) { print "\nextract is $1 \n"; } but thats perl. ;P Once again, thank you for any and all help. Link to comment Share on other sites More sharing options...
enaiman Posted October 9, 2008 Share Posted October 9, 2008 I'm afraid you can't do that - Help file quote:Each variable has a name (again, similar to a mailbox) and must start with the $ character and may only contain letters, numbers and the underscore _ character.AutoIt doesn't allow variable names having such a format. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted October 9, 2008 Author Share Posted October 9, 2008 I'm afraid you can't do that - Help file quote: AutoIt doesn't allow variable names having such a format. Below is HTML that I am pulling. These are not variables. $('user_group_size').innerHTML = "1489"; $('user_cash').innerHTML = "$198,519,293"; $('user_health').innerHTML = "323"; $('user_max_health').innerHTML = "323"; $('user_energy').innerHTML = "20"; $('user_max_energy').innerHTML = "120"; $('user_stamina').innerHTML = "12"; $('user_max_stamina').innerHTML = "15"; $('user_experience').innerHTML = "142006"; $('exp_for_next_level').innerHTML = "142507"; $('user_level').innerHTML = "150"; I would like to convert this HTML to stand alone variables for use with autoit. $('user_health').innerHTML = "323"; would convert to $user_health = 323, dynamically. (I hope I understood enough of what you said to get across what I'm trying to do.) Link to comment Share on other sites More sharing options...
enaiman Posted October 9, 2008 Share Posted October 9, 2008 Watch this topic too http://www.autoitscript.com/forum/index.php?showtopic=82274 because your problem made me look at "Assign". Any answer posted there might give you a clue. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 9, 2008 Share Posted October 9, 2008 $('\w+').innerHTML\s=\s"\d+"; or.. something like $('(.*?)').innerHTML\s=\s"(.*?)"; $Variable = $('(.*?)').innerHTML\s=\s".*?"; $Val = $('.*?').innerHTML\s=\s"(.*?)"; Is there a way to get around the quote issue? I've tried searching. (and is my syntax correct?) I know that I can get between the ' quote by using.. if($var =~ m/'(.*)'/) { print "\nextract is $1 \n"; } but thats perl. ;P Once again, thank you for any and all help. This pulls the values using StringRegExp(): #include <Array.au3> Global $avStrings[11] = ["$('user_group_size').innerHTML = ""1489"";", _ "$('user_cash').innerHTML = ""$198,519,293"";", _ "$('user_health').innerHTML = ""323"";", _ "$('user_max_health').innerHTML = ""323"";", _ "$('user_energy').innerHTML = ""20"";", _ "$('user_max_energy').innerHTML = ""120"";", _ "$('user_stamina').innerHTML = ""12"";", _ "$('user_max_stamina').innerHTML = ""15"";", _ "$('user_experience').innerHTML = ""142006"";", _ "$('exp_for_next_level').innerHTML = ""142507"";", _ "$('user_level').innerHTML = ""150"";"] Global $avRET, $iErrSav, $iExtSav Global $sPattern = "(?:\$\(\')(\w+)(?:\'\)\.innerHTML = "")(.+)(?:"";)" For $n = 0 To UBound($avStrings) - 1 ConsoleWrite("String = " & $avStrings[$n] & @LF) $avRET = StringRegExp($avStrings[$n], $sPattern, 3) $iErrSav = @error $iExtSav = @extended If @error = 0 Then If UBound($avRET) = 2 Then ConsoleWrite($avRET[0] & " = " & $avRET[1] & @LF & @LF) Else ConsoleWrite("Error - unexpected array size." & @LF & @LF) _ArrayDisplay($avRET, "Error") EndIf Else ConsoleWrite("@error = " & $iErrSav & " @extended = " & $iExtSav & @LF & @LF) EndIf Next This could also be done with non-RegExp string manipulation. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 9, 2008 Share Posted October 9, 2008 Watch this topic too http://www.autoitscript.com/forum/index.php?showtopic=82274 because your problem made me look at "Assign". Any answer posted there might give you a clue.Assign/Eval are evil I tell you! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted October 9, 2008 Share Posted October 9, 2008 Below is HTML that I am pulling. These are not variables. $('user_group_size').innerHTML = "1489"; $('user_cash').innerHTML = "$198,519,293"; $('user_health').innerHTML = "323"; $('user_max_health').innerHTML = "323"; $('user_energy').innerHTML = "20"; $('user_max_energy').innerHTML = "120"; $('user_stamina').innerHTML = "12"; $('user_max_stamina').innerHTML = "15"; $('user_experience').innerHTML = "142006"; $('exp_for_next_level').innerHTML = "142507"; $('user_level').innerHTML = "150"; I would like to convert this HTML to stand alone variables for use with autoit. $('user_health').innerHTML = "323"; would convert to $user_health = 323, dynamically. (I hope I understood enough of what you said to get across what I'm trying to do.)Why? What would be the point? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jacob_1998_1999 Posted October 9, 2008 Author Share Posted October 9, 2008 First of all, Thank you PSaltyDS. That RegEx is quite lovely. Sadly though.. I do not know how to edit the incoming HTML(add the extra quotes) with it on the fly. I still cannot even manage to get what you've written to show up in a msgbox. I'm going to include a sample HTML file. I'm certain there is a way to pull from raw html and end up with variables that contain values from the same source.Why?What would be the point?My goal is to have these variables available to be used in a script that I've written/am writing for this particular game.. So.. If the variable $user_health = <100 It would be told to go to a specific URL which would heal. Of course there is a little more to it than that.Thank you everyone that has tried so far to help me. jobs.htm Link to comment Share on other sites More sharing options...
trancexx Posted October 9, 2008 Share Posted October 9, 2008 First of all, Thank you PSaltyDS. That RegEx is quite lovely. Sadly though.. I do not know how to edit the incoming HTML(add the extra quotes) with it on the fly. I still cannot even manage to get what you've written to show up in a msgbox. I'm going to include a sample HTML file. I'm certain there is a way to pull from raw html and end up with variables that contain values from the same source.My goal is to have these variables available to be used in a script that I've written/am writing for this particular game.. So.. If the variable $user_health = <100 It would be told to go to a specific URL which would heal. Of course there is a little more to it than that.Thank you everyone that has tried so far to help me. I still fail to see the benefits. I think you should get familiar with the arrays, if not. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 9, 2008 Share Posted October 9, 2008 First of all, Thank you PSaltyDS. That RegEx is quite lovely. Sadly though.. I do not know how to edit the incoming HTML(add the extra quotes) with it on the fly. I still cannot even manage to get what you've written to show up in a msgbox. I'm going to include a sample HTML file. I'm certain there is a way to pull from raw html and end up with variables that contain values from the same source. My goal is to have these variables available to be used in a script that I've written/am writing for this particular game.. So.. If the variable $user_health = <100 It would be told to go to a specific URL which would heal. Of course there is a little more to it than that. Thank you everyone that has tried so far to help me. Well, it has finally seeped into the ossified parts of my brain that this is a game project, and I don't work on those (others here do, so you should still be able to get plenty of help). My parting thought is just that what you have is NOT HTML, it is javascript extracted from an HTML page. You might want to look at just using the .eval method of the document object in the IE DOM like this: ConsoleWrite("user_health = " & $oIE.document.parentwindow.Eval('user_health') & @CR) But that won't work as-is because what you are wanting to access is the .innerhtml of an object specified by $user_health in the Javascript. Look into simply finding the html element's object with the _IE* functions and just checking $oElement.innerhtml for the value you want. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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