I'm trying to parse:
<form id="main">
<select {disable} id="TRANSPORT" style="font-size: 8pt;margin:0;width:250px;">
<option selected value="TCP">
TCP(selected)
</option>
<option value="UDP">
UDP
</option>
</select>
</form>
selected value for the TRANSPORT. and I can't figure out how to do it. what I tried:
from bs4 import BeautifulSoup
f = '''<form id="main">\n
<select {disable} id="TRANSPORT" style="font-size:
8pt;margin:0;width:250px;"><option selected value="TCP">TCP(selected)
</option><option value="UDP">UDP</option></select>
</form>>'''
soup = BeautifulSoup(f, "lxml")
last_tag = soup.find("select",id ="TRANSPORT")
TRANSPORT_ID = last_tag.get('id')
TRANSPORT_VAL = last_tag.get('selected value')
print(TRANSPORT_ID, TRANSPORT_VAL)
I get the result:
TRANSPORT None
but I must get the result:
TRANSPORT TCP
because - TCP(selected)