在 Scrapy 為什么得到這個錯誤與日期格式不匹配我什至閱讀了它的檔案,我希望我的代碼與檔案相同
Published_Date = response.css('span[] ::text').get().strip().replace(",","").replace(".","")#Sept. 23, 2022
Published_Date = datetime.strptime(Published_Date, "%b %d %Y").date()
檔案鏈接https://www.programiz.com/python-programming/datetime/strptime
網站鏈接https://www.latimes.com/world-nation/story/2022-09-23/hong-kong-end-mandatory-covid-hotel-quarantine-travelers
uj5u.com熱心網友回復:
你為什么不這樣做:
published_date = response.xpath('//time[@]/@datetime').get().split('T')[0]
這樣您就可以獲取 ISO 格式的日期。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/518192.html
上一篇:您可以使用BeautifulSoup繞過“條款和條件”提示嗎?
下一篇:使用rvest抓取圖片
