获取带有beautifulsoup的div中的儿童文本

Si *_*Mon 7 html python urllib2 beautifulsoup

嗨,我想要在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"})
Run Code Online (Sandbox Code Playgroud)

使用此代码,我将获得此课程的全部内容.但我不能只获得其中的文字.我用next_silbing或.text尝试了很多东西,但它总是抛出错误(ResultSet没有属性xxx).

我只想得到这样的文字:"Die Android App von wetter.com!Sie erhalten:..:"

有人可以帮帮我吗?

Mar*_*ers 24

.text在元素上使用属性; 你有一个结果列表,所以循环:

for res in result:
    print res.text
Run Code Online (Sandbox Code Playgroud)

或者,如果只有一个这样的<div>,请使用.find()而不是.find_all():

result = soup.find("div", {"class":"show-more-content text-body"})
print result.text
Run Code Online (Sandbox Code Playgroud)