我想在一节中提取出文字网站的源代码。
我试图提取该网站的源代码如下所示:
if ('function' === typeof window.ToggleFilters) {
window.ToggleFilters();
}
</script>
<main id="main" data-danger="">
<section data-creation-date="2018-10-15 11:35:06">
<div class="detail__content">
我已经通过response.css和response.xpath试图尝试获取数据出来的源代码通过scrapy外壳没有运气。
response.xpath("//*[contains('data-creation')]")
我想只提取数据,创建日期,因此看起来像
'2018-10-15 11:35:06'
response.css('#main section::attr("data-creation-date")').extract_first()
要么
response.xpath("//@data-creation-date").extract_first()
要么
response.xpath("//main/section/@data-creation-date").extract_first()