为什么打印的不是Hello, 而是None

来源:4-7 BeautifulSoup4之获取父节点、祖先节点、兄弟节点

大可计划

2021-09-01 10:48:13

import requests
from bs4 import BeautifulSoup

html = """
<html>
<body>
<p class="story">
Once upon a time there were three little sisters; and their names were
<a href="http://example.com/elsie" class="sister" id="link1">
<span>Elsie</span>
</a>
Hello
<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a>
and
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>
and they lived at the bottom of a well.
</p>
"""

soup = BeautifulSoup(html, 'lxml')

print(soup.a.next_subling)


写回答

1回答

时间,

2021-09-01

同学,你好!获取下一个兄弟节点是next_sibling,同学写错了

https://img.mukewang.com/climg/612eee0209894a3e06700310.jpg

祝学习愉快!

0

0 学习 · 4469 问题

查看课程