I’m trying parse a html form that looks like that:
<select name="country">
<option value="1">Afghanistan</option>
<option value="2">Albania</option>
<option value="3">Algeria</option>
<option value="4">Andorra</option>
....
</select>
After I parse the document using lxml.html.parse, I can access the list of values using:
doc.forms[0].elements["country"].value_options
However, this returns a list of raw values ([‘1’, ‘2’, ‘3’, ‘4’ …]) without the corresponding country names. Is there an easy way to get the contents of the option tag including both text and values?
I use xpath to get go through html… try: