ThPucciano Posted May 7, 2013 Share Posted May 7, 2013 Hello!I try to read the source code of a html document and search for a string.The source code, what i read out with _IEDocReadHTML($oIE) are for examble:?({'url':'http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4'})I need to escape the string in saprate local variables.userid=username=time=server=flag=I try it with StringRegExp but i have in my string spetial caracters like the Quationmark or dots and gat a compile error.How can i do that? I'm new in Autoit and don't know next.Thanks Link to comment Share on other sites More sharing options...
Nessie Posted May 8, 2013 Share Posted May 8, 2013 I assume the you also need the value of variable, no?So in this example :?({'url':'http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4'})You want as result:userid=USERIDusername=USERNAMEtime=1367968978server=s5flag=76f8c752cacde3cfb5defc6900c19af4Right?Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
careca Posted May 8, 2013 Share Posted May 8, 2013 Will take some work, but you can do it with the trim functions. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Nessie Posted May 8, 2013 Share Posted May 8, 2013 Try this: #include <Array.au3> $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '[?&]+([^=&]+=[^&]*)', 3) _ArrayDisplay($aRegex) Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
ThPucciano Posted May 8, 2013 Author Share Posted May 8, 2013 #include <Array.au3> $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '[?&]+([^=&]+=[^&]*)', 3) _ArrayDisplay($aRegex) Yes this go in the right way, but i need only the value without the name. For example: Incomming String are: ?({'url':'http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4'}) them split it into 5 variabelsuserid=USERIDusername=USERNAMEtime=1367968978server=s5flag=76f8c752cacde3cfb5defc6900c19af4and then i can call the variabels, $UserID = JohnSmith; then i can rebuild my own link: _IENavigate($oIE, 'http://game.com/api/webgame/index.php?server=' & $oServer & 'username=' & $oUserName & '&callback=' & $oFlag, 1) But many Thanks for your help, i read first the referenz of this command and try. Link to comment Share on other sites More sharing options...
Nessie Posted May 8, 2013 Share Posted May 8, 2013 Try this: #include <Array.au3> ;Only for debug purpose $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '[?&]+[^=&]+=([^&]*)', 3) _ArrayDisplay($aRegex);Only for debug purpose If UBound($aRegex) - 1 <> 4 Then MsgBox(16, "Error", "Bad formatted link") Exit EndIf $s_userid = $aRegex[0] $s_username = $aRegex[1] $i_time = $aRegex[2] $s_server = $aRegex[3] $s_flag = $aRegex[4] Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
kylomas Posted May 9, 2013 Share Posted May 9, 2013 Simplified version #include <Array.au3> ;Only for debug purpose $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '([\w]+)=', 3) _ArrayDisplay($aRegex);Only for debug purpose kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ThPucciano Posted May 9, 2013 Author Share Posted May 9, 2013 (edited) Its work fine, Thanks , but the last variable have the HTML Tag inside: 85cc3298681991d300d97d0a43605c45'})</BODY></HTML> How can i cut the part '})</BODY></HTML> ? Or can i select the lenght of the variable? I need the first 32 letters of the string. Simplified version #include <Array.au3> ;Only for debug purpose $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '([\w]+)=', 3) _ArrayDisplay($aRegex);Only for debug purpose kylomas Your Version only find the string, but not the value of the String. Edited May 9, 2013 by ThPucciano Link to comment Share on other sites More sharing options...
Nessie Posted May 9, 2013 Share Posted May 9, 2013 Try this: #include <Array.au3> ;Only for debug purpose $sString = "?({'url':'http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4'})</BODY></HTML>" $aRegex = StringRegExp($sString, "(?s).=(\w+)", 3) _ArrayDisplay($aRegex);Only for debug purpose If UBound($aRegex) - 1 <> 4 Then MsgBox(16, "Error", "Bad formatted link") Exit EndIf $s_userid = $aRegex[0] $s_username = $aRegex[1] $i_time = $aRegex[2] $s_server = $aRegex[3] $s_flag = $aRegex[4] Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
kylomas Posted May 9, 2013 Share Posted May 9, 2013 THPucciano,Your Version only find the string, but not the value of the String. I Thought that was what you wanted since you are going to rebuild my own link:and commented that but i need only the value without the nameMy misunderstandingkylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted May 9, 2013 Share Posted May 9, 2013 (edited) Or can i select the lenght of the variable? I need the first 32 letters of the string.If this means that you want the base URL then try this, base URL plus the value on the right side of each "=" sign.#include <Array.au3> ;Only for debug purpose $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, '(?s)^.+\?|=(\w+)', 3) _ArrayDisplay($aRegex);Only for debug purposekylomasedit: shamelessly copied from Nessie's SRE Edited May 9, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
ThPucciano Posted May 9, 2013 Author Share Posted May 9, 2013 I have try this:$sFlag = StringTrimRight($aRegex[4], 17)Its work fine, but what is when the Input are not the same? I cut the 17 carackters from right.If is possible to Cut out directly by the StringRegExp ? Link to comment Share on other sites More sharing options...
jdelaney Posted May 9, 2013 Share Posted May 9, 2013 (edited) yet another way #include <Array.au3> ;Only for debug purpose Enum $iKey = 1, $iKey_value $sString = "http://api.game.com/login.php?userid=USERID&username=USERNAME&time=1367968978&server=s5&flag=76f8c752cacde3cfb5defc6900c19af4" $aRegex = StringRegExp($sString, "(\w+)\=(\w+)", 4) For $i = 0 To UBound($aRegex)-1 $aTemp = $aRegex[$i] ConsoleWrite("Key=[" & $aTemp[$iKey] & "], KeyValue=[" & $aTemp[$iKey_value] & "]" & @CRLF) Next Key=[userid], KeyValue=[uSERID] Key=[username], KeyValue=[uSERNAME] Key=[time], KeyValue=[1367968978] Key=[server], KeyValue=[s5] Key=[flag], KeyValue=[76f8c752cacde3cfb5defc6900c19af4] Edited May 9, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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