1 回答
TA贡献1827条经验 获得超8个赞
尝试这个:
for i in soup.find_all('div',class_="product-description"):
try:
print(i.find_all('p')[-1].text)
except:
pass
这里的汤是:
<div class="product-description">
<p> "Title" </p>
<p> "Some content" </p>
<p> "Product description" </p>
</div>
<div class="product-description">
<p> "Title" </p>
<p> "Product description" </p>
</div>
<div class="product-description">
<p> "Title" </p>
<p> "Some content" </p>
<p> "Some content" </p>
<p> "Product description" </p>
</div>
<div class="product-description">
<p> "Title" </p>
<p> "Some-content" </p>
<p> "Some-content" </p>
<p> "Some-content" </p>
<p> "Product description" </p>
</div>
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报