为了得到
span title
from bs4 import BeautifulSoup
html ="""<div id="ember3815" class="ember-view">
<p class="org-top-card-module__company-descriptions Sans-15px-black-55%">
<span class="company-industries org-top-card-module__dot-separated-list">
Industry
</span>
<span class="org-top-card-module__location org-top-card-module__dot-separated-list">
City, State
</span>
<span title="62,346 followers" class="org-top-card-module__followers-count org-top-card-module__dot-separated-list">
62,346 followers
</span>"""
soup = BeautifulSoup(html, "html.parser")
print( soup.find("span", class_="org-top-card-module__followers-count org-top-card-module__dot-separated-list")["title"])
输出:
62,346 followers
对于站点2
print( soup.find("a", class_="g47SY")["title"])