Beautiful Soup 中没有内置的 continue 函数,但是可以使用 Python 中的 continue 关键字来实现类似的功能。例如:
from bs4 import BeautifulSoup
html_doc = """
The Dormouse's story
Once upon a time there were three little sisters; and their names were Elsie, Lacie and Tillie; and they lived at the bottom of a well.
...
"""soup = BeautifulSoup(html_doc, 'html.parser')
for link in soup.find_all('a'): if link.get('id') == 'link2': continue print(link.get('href'))
在这个例子中,我们使用了 find_all 函数来查找所有的 a 标签,当遇到 id 为 link2 的标签时,使用 continue 关键字跳过该标签,继续执行循环体内的语句。