OS X Need help with re: function
#1
Hi Friends,
Newbie here and trying to write my first script in python, learnt a lot of new things over last few days.

My script logs into a site with a user id/pwd and then derives streaming information. I am required to also pass a dynamic hidden password from the page source when posting the form to login.

I have following string in my login page source which carries the hidden password -

("#login_password_").val('qM2YmqibpqVjpmefqdWUn36/i5yo5KOUneZoag==');

Inorder to post the form to the server, I need to pass hidden password value which is the value in BLUE above.

Could somebody help me with how do I filter out the hidden password value (ie 'qM2YmqibpqVjpmefqdWUn36/i5yo5KOUneZoag==' in above sample) from the source string using re: function.

Spent lot of time reading http://docs.python.org/2/library/re.html but not able to figure out on my own. L

Thanks in advance.
Reply
#2
pattern = "\(\"#login_password_\"\).val\('(.+?)'\);"
re.findall(pattern, pagesource)

Maybe Smile I'm not real sure how to handle both single and double quotes in a string.
Reply
#3
(2013-02-09, 18:06)divingmule Wrote: pattern = "\(\"#login_password_\"\).val\('(.+?)'\);"
re.findall(pattern, pagesource)

Maybe Smile I'm not real sure how to handle both single and double quotes in a string.

Works perfect. Thanks so much divingmule. Highly appreciate.

Reply
#4
You really need to pass on that scrip to me bro... I am such a dumb with python script Sad please I request.>
Reply
#5
As an alternative, you can use triple single quotes as a third type of quotes:
Code:
pattern = '''\("#login_password_"\).val\('(.+?)'\);'''
re.findall(pattern, pagesource)
Reply

Logout Mark Read Team Forum Stats Members Help
Need help with re: function0