【发布时间】:2023-03-07 16:22:01
【问题描述】:
你好,有什么方法可以使用 requests-HTML 获取标签的所有父元素?
例如:
<!DOCTYPE html>
<html lang="en">
<body id="two">
<h1 class="text-primary">hello there</h1>
<p>one two tree<b>four</b>five</p>
</body>
</html>
我想得到b标签的所有父母:[html, body, p]
或者对于h1标签得到这个结果:[html, body]
【问题讨论】:
标签: python html python-3.x web-crawler python-requests-html