I need to pull the URL after logging into a website and extract the session id (sid=) from the URL. Ideas?
Thanks,
Jim
Parse URL to obtain SID
Re: Parse URL to obtain SID
You can find SID by using regular expressions.
See example below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Note: It is possible to avoid of usage of regular expressions, but the algorithm will be a bit more complex.
See example below
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task11"
Hide=INTEGER|0
ID=INTEGER|1022341075
LogOnAsUser=INTEGER|1
Name=STRING|"Extract SID from URL"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""MYURL"" with value ""http://www.mysite.com?sid=1234567890abcdef¶m=a..."""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"MYURL"
varvalue=STRING|"http://www.mysite.com?sid=1234567890abcdef¶m=asdf¶m=zxcv"
[Actions\Action10]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""SID is not found"""
Params=FOLDER
[Actions\Action10\Params]
icon=STRING|"0"
msg0=STRING|"SID is not found"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action11]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action12]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action2]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER
[Actions\Action2\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{MyURL}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)sid=([^&]+)$"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"
[Actions\Action3]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{found}"
[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Found! Expression is:"""
Params=FOLDER
[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"Found! Expression is:"
msg1=STRING|"sid : {expr(1)}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action5]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"
[Actions\Action6]
ActionID=STRING|"A_REGEXP_MATCH"
Enabled=INTEGER|-1
Name=STRING|"RegExp Match"
Params=FOLDER
[Actions\Action6\Params]
anchored=STRING|"0"
case=STRING|"0"
extended=STRING|"0"
line00000000=STRING|"{MyURL}"
linecount=STRING|"1"
multiline=STRING|"0"
noautocapture=STRING|"0"
pattern=STRING|"(?i)sid=([^&]+)&"
savesubexpression=STRING|"1"
singleline=STRING|"0"
subexpressionpos=STRING|"0"
subexpressionvar=STRING|"expr"
ungreedy=STRING|"0"
useexternal=STRING|"0"
variable=STRING|"found"
[Actions\Action7]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action7\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"3"
value1=STRING|"{found}"
[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Found! Expression is:"""
Params=FOLDER
[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"Found! Expression is:"
msg1=STRING|"sid : {expr(1)}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action9]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"
Note: It is possible to avoid of usage of regular expressions, but the algorithm will be a bit more complex.
Oleg Yershov