python 处理html中 class中存在空格 获取问题
html = """<h1 class='td p1'> 0000000000000000000000000 </h1> <h1 class='td p2'> 123333333333333333333 </h1> <h1 class='p2'> 111111111111111111111111111111111111 </h1>""" soup = BeautifulSoup(html, "lxml") content = soup.find('h1', attrs={'class':'td p1'})
>>> print(content) <h1 class="td p1">
0000000000000000000000000
</h1>