这是我使用find()
一次后获得的结构。
<component-thread-list :assignee-id="'44756'" :assignee-type="'professional'" :assignee-username="'bs-dangquanghuy'" :change-comment="false" :change-link="''" :email="'drdangquanghuy@gmail.com'" :is-linked-with-place="false" :is-staff="false" :tag-name="''" :tag-slug="''" :thread-create-share-button-showing="false" :verified="'True'" :view-name="'professional-detail'" assignee-name="Đặng Quang Huy" occupation="Bác sĩ" professional-name="">
<div class="loading-screen">
<div class="timeline-item no-margins">
<div class="animated-background facebook">
<div class="background-masker header-top"></div>
<div class="background-masker header-left"></div>
<div class="background-masker header-right"></div>
<div class="background-masker header-bottom"></div>
<div class="background-masker subheader-left"></div>
<div class="background-masker subheader-right"></div>
<div class="background-masker subheader-bottom"></div>
<div class="background-masker content-top"></div>
<div class="background-masker content-first-end"></div>
<div class="background-masker content-second-line"></div>
<div class="background-masker content-second-end"></div>
<div class="background-masker content-third-line"></div>
<div class="background-masker content-third-end"></div>
</div>
</div>
</div>
</component-thread-list>
如何使用Beautiful soup访问电子邮件地址?
答案 0 :(得分:0)
您可以使用:
soup = BeautifulSoup(xml, 'lxml') # xml is the XML you've provided
email = soup.find('component-thread-list')[':email']
print(email)
# 'drdangquanghuy@gmail.com'
print(email[1:-1])
# drdangquanghuy@gmail.com