Kodi Community Forum
OS X Need help with re: function - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: OS X Need help with re: function (/showthread.php?tid=155521)



Need help with re: function - Master2312 - 2013-02-09

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.


RE: Need help with re: function - divingmule - 2013-02-09

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.


RE: Need help with function - Master2312 - 2013-02-09

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




RE: Need help with re: function - coolboyrahul - 2013-02-18

You really need to pass on that scrip to me bro... I am such a dumb with python script Sad please I request.>


RE: Need help with re: function - Bstrdsmkr - 2013-02-18

As an alternative, you can use triple single quotes as a third type of quotes:
Code:
pattern = '''\("#login_password_"\).val\('(.+?)'\);'''
re.findall(pattern, pagesource)