📌  相关文章
📜  python beautifulsoup 获取选项标签值 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:48.485000             🧑  作者: Mango

代码示例1
# Import Module
from bs4 import BeautifulSoup
import requests

# Get HTML Content
r = requests.get("Enter Web URL:- ")

# Parse HTML Content
soup = BeautifulSoup(r.content, 'html.parser')

# Find select tag
select_tag = soup.find("select")

# find all option tag inside select tag
options = select_tag.find_all("option")

# Iterate through all option tags and get inside text
for option in options:
    print(option.text)