首页 > 解决方案 > 从 bs4 find_all 函数返回文本

问题描述

我目前正在尝试解决此问题(BeautifulSoup):

crypto_name = soup.find_all("p",class_="sc-1eb5slv-0 iJjGCS") print(crypto_name)

返回:

[<p class="sc-1eb5slv-0 iJjGCS" color="text" font-size="1" font-weight="semibold">Bitcoin</p>, <p class="sc-1eb5slv-0 iJjGCS" color="text" font-size="1" font-weight="semibold">Ethereum</p>

我只需要它来返回比特币和以太币。但我真的不知道该怎么做。

标签: pythonbeautifulsoup

解决方案


循环遍历结果并获得.text教学项目。

cryptos = [item.text for item in crypto_name]

推荐阅读