📜  Beautifulsoup 父级 - Python 代码示例

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

代码示例4
from bs4 import BeautifulSoup

# Html source
html = """

Recent Posts:

""" # Parse soup = BeautifulSoup(html, 'html.parser') # Get h2 tag h2 = soup.h2 # Print h2 parent print(h2.parent)