Say I have many options in a HTML page (opened as text file) as below,
<select id="my">
<option id="1">1a</option>
<option id="2">2bb</option>
</select>
<select id="my1">
<option id="11">11a</option>
<option id="21">21bb</option>
</select>
Now, I've searched for <select id=
with open('/u/poolla/Downloads/creat/xyz.txt') as f:
for line in f:
line = line.strip()
if '<select id=' in line:
print "true"
Now, whenever <select id= occurs, I want to get the id value.
that is, copy the string from " after id= till another " occurs
how do I do this in python?
BeautifulSoup: stackoverflow.com/questions/1732348/…re.findall('id=".*?"', line)[0][4:-1]yw...lxml, if installed, is the default, right? BeautifulSoup 4 is not about parsing (anymore) but about the object model. Which is pretty neat for most HTML tasks, really.lxmlif you want to use the ElementTree-on-steroids object model instead. Don't pick it because you think the parser might be better...