【发布时间】:2018-07-17 14:56:59
【问题描述】:
我正在使用 Python Anaconda 将数据抓取到 Excel 工作表中。我在两个网站上遇到了一些问题。
网站 1
<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>
我正在尝试提取跨度标题。我尝试过的东西(我也尝试过所有作为 find_all 的东西):
text = soup.find('span',{'class':"company-industries org-top-card-module__dot-separated-list"})
text = soup.find('p',{'class':"org-top-card-module__company-descriptions Sans-15px-black-55%"})
text = soup.body.find('span', attrs={'class': 'org-top-card-module__location org-top-card-module__dot-separated-list'})
text = soup.find('span',{'class': 'org-top-card-module__location org-top-card-module__dot-separated-list'})
我确定我还尝试过其他一些我没有列出的东西,因为我不记得所有的东西。我不是程序员,我只是想弄清楚这一点以提取数据进行分析。帮助?
站点 2
我需要从下面的 html 中提取值 8,052。
<section class="zwlfE">
<div class="nZSzR">...</div>
<ul class="k9GMp ">
<li class="Y8-fY ">...</li>
<li class-"Y8-fY ">
<a class="g47SY " title="8,052">8,052</span>" followers"
</a>
</li>
<li class="Y8-fY ">...</li>
</ul>
<div class="-vDIg">...</div>
</section>
我试过了:
- text = soup.find('span',{'class': "g47SY "})
- 与上面类似,但带有 div 和 li 标签
我尝试过的所有结果都是 []。
请帮忙?
【问题讨论】:
标签: python web-scraping beautifulsoup anaconda