<div class="information-list__item l-column small-12 medium-6 large-4 small-valign-top">
<dt class="information-list__item__term medium-valign-top">Supplier</dt>
<dd class="information-list__item__definition">
Elmar Groetsch
</dd>
</div>
在 Scrapy 或 BeautifulSoup 中,如何提取值 'Supplier' 和 'Elmar Groetsch'?在这种情况下,供应商是关键,Elmar Groetsch 是价值。
这不起作用:
supplier = response.css('div.information-list__item')[0]
如何使用 class="" 部分中的多个标签?
答案 0 :(得分:0)
这些将分别返回供应商和 Elmar Groetsch
soup = BeautifulSoup(html, "html.parser")
soup.find('div', class_='information-list__item l-column small-12 medium-6 large-4 small-valign-top').find('dt').text
soup.find('div', class_='information-list__item l-column small-12 medium-6 large-4 small-valign-top').find('dd').text