标签:
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("index.html"))
soup = BeautifulSoup("<html>data</html>")
from bs4 import SoupStrainer
only_a_tags = SoupStrainer("a")
only_tags_with_id_link2 = SoupStrainer(id="link2")
def is_short_string(string):
return len(string) < 10
only_short_strings = SoupStrainer(text=is_short_string)
BeautifulSoup(html_doc, "html.parser", parse_only=only_a_tags)
标签:
原文地址:http://www.cnblogs.com/dmdj/p/4213103.html