您好,我想要 Google Play 商店中应用程序的描述。 ( https://play.google.com/store/apps/details?id=com.wetter.androidclient&hl=de )
import urllib2
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen("https://play.google.com/store/apps/details?id=com.wetter.androidclient&hl=de"))
result = soup.find_all("div", {"class":"show-more-content text-body"})
使用此代码,我获得了此类中的全部内容。但我不能只得到其中的文字。我用 next_silbing 或 .text 尝试了很多东西,但它总是抛出错误(ResultSet 没有属性 xxx)。
我只想得到这样的文字:“Die Android App von wetter.com!Sie erhalten:..:”
任何人都可以帮助我吗?
原文由 Si Mon 发布,翻译遵循 CC BY-SA 4.0 许可协议
在元素上使用
.text
属性;你有一个结果 _列表_,所以循环:.text
是代表Element.get_text()
方法 的属性。或者,如果只有 一个 这样的
<div>
,请使用.find()
而不是.find_all()
: