【发布时间】:2022-07-27 16:36:27
【问题描述】:
我使用这段代码来获取元素div.entry-content的内容:
item['description'] = response.css('div.entry-content').get()
但是,它也返回包装元素:
<div class="entry-content">
<p>**my content**</p>
</div>
但我只想要内容,所以就我而言:<p>**my content**</p>
我还尝试了 xpath 选择器response.xpath('//div[@class="entry-content"]').get(),但结果与上述相同。
我试过谷歌搜索,但找不到任何东西。
【问题讨论】:
标签: python web-scraping