如何使用 BeautifulSoup 获取选择的选项

How to get the option selected using BeautifulSoup

我正在使用 Python3.7 和 BeautifulSoup4,我仍在学习如何使用 python 和 BeautifulSoup 进行爬坡,我在 [=41 中有一个页面=] 我想得到所有选项 selected。

这是我的代码:

ZeroDay = s.post("https://site/Add_Studant.php",data={"SID":123456})
    ZeroDay_content = bs(ZeroDay.content,"html.parser", from_encoding='windows-1256')
    std_ID    = ZeroDay_content.find("input", {"name":"SID[]"})["value"]
    std_name  = ZeroDay_content.find("input", {"name":"Name[]"})["value"]
    std_major_= ZeroDay_content.select_one("option[selected]", {"name":"Qualifications[]"})["value"]
    std_major = ZeroDay_content.find("input", {"name":"Specialization[]"})["value"]
    std_social= ZeroDay_content.select_one("option[selected]", {"name":"MILITARY_STATUS[]"})["value"]
    std_ID_num= ZeroDay_content.find("input", {"name":"ID_Number[]"})["value"]
    std_gender= ZeroDay_content.select_one("option[selected]", {"name":"Gender[]"})["value"]
    print(std_ID,std_name,std_gender,std_major,std_major_,std_ID_num,std_social)

在我 运行 代码之后,结果不包含 std_social 和 std_gender 的值,我想是因为我使用了 select_one 两次,但我在互联网上搜索了很多关于所有不适用于我的代码的解决方案。

这是第一个 select 组 html 中的页面:

 <select class="form-control" name="Qualifications[]"  style="padding:5px;"><!-- the id is important in validation -->
                      <option value="user" >user</option>
                      <option value="admin" selected> admin</option>

第二select组:

 <select class="form-control" name="MILITARY_STATUS[]" >
                      <option value="USA" >USA</option>
                      <option value="sy" selected>sy</option>
                      <option value="pal" >pal</option>
                      <option value="jordan" >jordan</option>

在我 运行 代码之后它只显示管理值而不是我需要的 admin 和 sy

我在这里检查了这些链接,但没有结果:

Find the selected option using BeautifulSoup

python BeautifulSoup get select.value not text

How to get the option text using BeautifulSoup

name属于select,不属于option

std_social= ZeroDay_content.select_one("select[name='MILITARY_STATUS[]'] option[selected]")["value"]