如何使用BeautifulSoup在没有任何id的范围内获取文本

时间:2017-07-24 14:00:03

标签: python-2.7 beautifulsoup

<span onclick="selectText('email_ch_text')" id="email_ch_text">10005000986@ambiancewe.us</span>

如何使用beautifoulsoup“10005000986@ambiancewe.us”

1 个答案:

答案 0 :(得分:0)

使用此代码:

html_doc = "<span onclick=\"selectText('email_ch_text')\" id=\"email_ch_text\">10005000986@ambiancewe.us</span>"

from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')

print(soup.span.text)