【发布时间】:2017-11-03 09:17:00
【问题描述】:
我正在尝试使用 beautifulsoup 从 beeradvocate 中获取评论。审核代码如下所示:
[<span class="BAscore_norm">4.49</span>,
<span class="rAvg_norm">/5</span>,
u'\xa0\xa0rDev ',
<span style="color:#006600;">+2%</span>,
<br/>,
<span class="muted">look: 4.25 | smell: 4.5 | taste: 4.5 | feel: 4.5 |
overall: 4.5</span>,
<br/>,
<br/>,
u'Pours a slightly hazy golden orange with two fingers white head. ',
<br/>,
u'\nSmells of citrus, orange, pineapple, sweet malty presence.',
<br/>,
u'\nTastes starts with the juicy orange, pineapple. Finishes with a
somewhat sweet caramel toffee like malt presence.',
<br/>,
u'\nVery smooth medium body. Alchohol was very well hidden until it started
to warm a bit.',
<br/>,
u'\nOverall a really tasty brew!',
<br/>,
<br/>,
<i aria-hidden="true" class="fa fa-file-text-o"></i>,
u'\xa0',
<span class="muted">354 characters</span>,
<br/>,
<br/>,
<div><span class="muted"><a class="username"
href="/community/members/jbowengeorgia.1171914/">JBowenGeorgia</a>, <a
href="/beer/profile/26/1558/?ba=JBowenGeorgia#review">Oct 03, 2017</a>
</span></div>]
我不知道如何提取评论的文本。 Python BeautifulSoup extract text between element 有一个类似的问题,但大多数答案都涉及 .contents 和位置参数,由于评论中段落之间的换行符,这在此处不起作用。
【问题讨论】:
-
如果有初始的 html 代码,而不仅仅是来自 python 的打印,那就太好了。
标签: python beautifulsoup