作者:IT小样
通过之前的系列我们现在已经了解了BeautifulSoup的属性、操作,现在我们来一起学习一下如何搜索文档树。
1、find_all()方法
find_all()方法,找到所有匹配,关于传入参数,可以传入各种类型,接下来介绍不同过滤器。
1.1、过滤器
1.1.1、字符串过滤器
仍然以之前的html_doc为例,来进行示范:
html_doc = '''
<html><head><title>hello,tester</title></head><body>
<p class="title"><b><h1>Hello,welcome</h1></b></p>
<p class="documentation">Tester, welcome! This is a new partion of your job's life. With python, you can finnish your work easier and faster.How, <a href="http://example.com/easier" class="easier" id="link1"> easier </a> and <a href="http://example.com/faster" class="faster" id = "link2">faster</a> Now, you have a initial impression about python.</p>
<p class="documention">let's go!!!</p>
</body></html>
'''
from bs4 import BeautifulSoup
sou