parsing - How to parse a string in python -
without 3rd party libraries (such beautiful soup) cleanest way parse string in python.
given text below i'd content of "uber_token" parsed out ie. "123456789"
....
<form id="blah" action="/p-submi.html" method="post"><input type="hidden" id="" name="uber_token" value="123456789"/><div class="container-info">
....
thanks!
regular expression solution.
use import re
>>> import re >>> s = '<form id="blah" action="/p-submi.html" method="post"><input type="hidden" id="" name="uber_token" value="123456789"/><div class="container-info"' >>> regex=re.search(r'name="uber_token" value="([0-9]+)"',s) >>> print regex.group(1) 123456789
Comments
Post a Comment