from bs4 import BeautifulSoup
import re
html = """
<div class="ACA_TabRow ACA_FLeft">
Mailing
<br/>
1961 MAIN ST #186
<br/>
WATSONVILLE, CA, 95076
<br/>
United States
<br/>
</div>
"""
soup = BeautifulSoup(html,"lxml")
items = soup.find(class_="ACA_TabRow")
items_list = items.text.split('\n')
results = [ x.strip() for x in items_list if x.strip() != '' ]
输出:
print (results)
['Mailing', '1961 MAIN ST #186', 'WATSONVILLE, CA, 95076', 'United States']
有只小跳蛙
相关分类