【发布时间】:2017-10-24 17:28:45
【问题描述】:
<a href="link" target="_blank" class="xXx text-user topic-author" sl-processed="1">
diamonds
</a>
我想用 BeautifulSoup 提取“a”标签中的伪“钻石”。
我尝试了很多东西,但总是返回“无”。
对我来说应该起作用的是这个
txt = soup.find('a', {'class': 'xXx text-user topic-author'})
print (txt)
【问题讨论】:
-
请分享您的尝试。
-
@eLRuLL 对不起,我已经编辑了!
-
你对钻石这个词很感兴趣?
-
@jlaur 是的,我是。
-
将html加载到一个名为soup的对象中。 a = 汤。钻石 = a.text.strip()
标签: python css beautifulsoup