【发布时间】:2019-06-03 12:21:05
【问题描述】:
我需要从 HTML 文档中标签的 datetime 属性中提取评论的日期。
我一直在尝试使用 xpath 和 css 选择器的不同变体来实现这一点,但它们返回空字符串。
HTML 标记如下所示:
<time class="review-date--tooltip-target" datetime="2013-10-09T13:47:14.000Z" title= "Wednesday, 9 October 2013, 13:47:14">9 Oct 2013</time>
还有,这是我的 xpath 和 css 选择器:
xpath('//time[@class="review-date--tooltip-target"]')
css('time.review-date--tooltip-target')
两个结果将帮助我:
1- extract the value of the `datetime` attribute
2- extract the text `9 Oct 2013` within the time tag
【问题讨论】:
标签: python-3.x xpath web-scraping scrapy