Issue
In Scrapy Why getting this Error not match the date format I Even read its documentation and I hope I am doing code same to the documentation
Published_Date = response.css('span[class="published-date-day"] ::text').get().strip().replace(",","").replace(".","")#Sept. 23, 2022
Published_Date = datetime.strptime(Published_Date, "%b %d %Y").date()
documentation link https://www.programiz.com/python-programming/datetime/strptime
website link https://www.latimes.com/world-nation/story/2022-09-23/hong-kong-end-mandatory-covid-hotel-quarantine-travelers
Solution
Why don't you do:
published_date = response.xpath('//time[@class="published-date"]/@datetime').get().split('T')[0]
This way you obtain the date in ISO format.
Answered By - Barry the Platipus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.