标签: python html5 dom
以下代码以HTML格式输出。我对DOCTYPE很困惑。这里的HTML标签的父级是什么?是DOCTYPE吗?
html = list(soup.children)[1] print(html)
答案 0 :(得分:0)
DOCTYPE是顶级声明,而不是< html>的父级。元件。
美丽的汤the BeautifulSoup object you get from the parser is the container for both the DOCTYPE and the root HTML element。
BeautifulSoup
另见Get document DOCTYPE with BeautifulSoup