我们查找文档中的href="http://example.com/lacie"的节点元素<a>from bs4 import BeautifulSoupdoc='''<html><head><title>The Dormouse's story</title></head><body><a href="http://example.com/elsie" >Elsie</a><a href="http://example.com/lacie" >Lacie</a><a href="http://example.com/tillie" >Tillie</a></body></html>'''def myFilter(tag): print(tag.name) __________________________________________soup=BeautifulSoup(doc,"lxml")tag=soup.find_all(myFilter)print(tag)缺失的语句是:
A、return (tag.name=="a" and tag["href"]=="http://example.com/lacie");
B、return (tag.name=="a" and tag.has_attr("href") and tag["href"]=="http://example.com/lacie");
C、return (tag.name=="a" and tag.has_attr("href") and tag.href=="http://example.com/lacie");
D、return (tag.name=="a" and tag.href=="http://example.com/lacie")
发布时间:2025-02-18 01:06:09