Home > front end >  In Scrapy Why getting this Error not match the date format I Even read its documentation and I hope
In Scrapy Why getting this Error not match the date format I Even read its documentation and I hope

Time:10-19

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[] ::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

CodePudding user response:

Why don't you do:

published_date = response.xpath('//time[@]/@datetime').get().split('T')[0]

This way you obtain the date in ISO format.

  • Related