我正在尝试将下拉菜单中当前选择的值存储到一个变量中,但我在 Python 中找不到正确的方法。我可以通过选择元素并键入来打印整个列表print element.text
,但我希望能够存储所选元素。
这是下拉菜单的html。
<select id="offer.sections.edit.jobHighlights.permanentLocationId" onchange="OWF_synchronizeQualifiedRelocationPackages(); OWF_selectCompanyBySelectedLocation()" onblur="OWF_showChangedControl(this)" name="offer.permanentLocationId">
<option value=""/>
<option value="AE-DXB-DIC9">AE-DXB-DIC9: Dubai, United Arab Emirates</option>
<option value="AE-HOME-35819">AE-HOME-35819: Home-Gawdat, Dubai, UAE</option>
<option value="AR-BUE-ALI">AR-BUE-ALI: Buenos Aires, Argentina</option>
<option value="AR-REMOTE-GEN">AR-REMOTE-GEN: Argentina - Remote</option>
<option value="AT-REMOTE-GEN">AT-REMOTE-GEN: Austria - Remote</option>
<option value="AT-VIE-GRA">AT-VIE-GRA: Vienna, Austria</option>
<option value="AU-HOME-22038">AU-HOME-22038: Home-Whitlow, Carlton, AU</option>
<option value="AU-HOME-23104">AU-HOME-23104: Home-Miller, Brunswick, AU</option>
<option value="AU-HOME-49114">AU-HOME-49114: Home-Whiteman, Brighton East, AU</option>
<option value="AU-REMOTE-GEN">AU-REMOTE-GEN: Australia - Remote</option>
<option value="AU-SYD-PIR">AU-SYD-PIR: Sydney, Australia</option>
<option value="BA-REMOTE-GEN">BA-REMOTE-GEN: Bosnia and Herzegovina - Remote</option>
<option value="BE-BRU-ETT">BE-BRU-ETT: Brussels, Belgium</option>
<option value="BE-GHL-DAT1">BE-GHL-DAT1: Data Center, Ghlin, Belgium</option>
<option value="BE-REMOTE-GEN">BE-REMOTE-GEN: Belgium - Remote</option>
<option value="BG-REMOTE-GEN">BG-REMOTE-GEN: Bulgaria - Remote</option>
<option value="BR-BAR-DAT1">BR-BAR-DAT1: Barueri, Brazil</option>
<option value="BR-BHZ-THT" selected="selected">BR-BHZ-THT: Belo Horizonte, Brazil</option>
<option value="BR-REMOTE-GEN">BR-REMOTE-GEN: Brazil - Remote</option>