Jump to content

Escape html source for a string to split it


Recommended Posts

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

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=USERID
  • username=USERNAME
  • time=1367968978
  • server=s5
  • flag=76f8c752cacde3cfb5defc6900c19af4
Right?

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

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

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

#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 variabels

  • userid=USERID
  • username=USERNAME
  • time=1367968978
  • server=s5
  • flag=76f8c752cacde3cfb5defc6900c19af4
and 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

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

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

Its work fine, Thanks :thumbsup: , 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 by ThPucciano
Link to comment
Share on other sites

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

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 name

My misunderstanding

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

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 purpose

kylomas

edit: shamelessly copied from Nessie's SRE ;)

Edited 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

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 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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...