【发布时间】:2014-09-25 00:09:28
【问题描述】:
我正在尝试提取该数据:
<div class="address"><h3>Text1</h3><div class="adr">Text2</div></div>
我想打印 text1 和 text2。
我试试这个:
br = mechanize.Browser()
html = """<div class="address"><h3></h3><div class="adr"></div></div>"""
soup = BeautifulSoup(html)
br.addheaders = [('User-agent', 'Firefox')]
br.open("http://de.fakenamegenerator.com/gen-male-gr-gr.php")
adress = soup.findAll('div', attrs={ "class" : "adr"})
print len(adress)
我得到了结果:
1
...
谢谢!
【问题讨论】:
标签: python html html-parsing beautifulsoup mechanize