Issue
I need to extract the date of the review from the datetime attribute of the tag in an HTML document.
I've been attempting to use different variations of xpath and css selector to achieve this but they return empty strings.
the HTML tag looks like below:
<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>
and, here's my xpath and css selector:
xpath('//time[@class="review-date--tooltip-target"]')
css('time.review-date--tooltip-target')
two outcomes will help me:
1- extract the value of the `datetime` attribute
2- extract the text `9 Oct 2013` within the time tag
Solution
For Scrapy you need:
datetime = response.xpath('//time[@class="review-date--tooltip-target"]/@datetime').extract_first()
time = response.xpath('//time[@class="review-date--tooltip-target"]/text()').extract_first()
Answered By - gangabass
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.