Hello,
The following code works in other scripts that read an RSS feed, but for some reason, this one doesn't work with another site.
As shown, I tried .split() in case it had a carriage return, but it makes no difference:
Thank you.
--
Edit: Found it here: "don't confuse %Z (timezone abbr) and %z (numeric offset)"
This works:
The following code works in other scripts that read an RSS feed, but for some reason, this one doesn't work with another site.
As shown, I tried .split() in case it had a carriage return, but it makes no difference:
URL="https://feeds.acme.com/blah.xml" resp = requests.get(URL) soup = BeautifulSoup(resp.text,'xml') for item in soup("item"): title=item.title.string link=item.link.string #<pubDate>Mon, 28 Oct 2024 07:44:18 GMT</pubDate> #ValueError: time data 'Mon, 28 Oct 2024 07:44:18 GMT' does not match format '%a, %d %b %Y %H:%M:%S %z' date_obj = dt.datetime.strptime(item.pubDate.string, "%a, %d %b %Y %H:%M:%S %z") #NO DIFF date = item.pubDate.string.strip() #date_obj = dt.datetime.strptime(date, "%a, %d %b %Y %H:%M:%S %z") pubDate = "{} {} {}".format(date_obj.day,date_obj.strftime("%b"),date_obj.year)Any idea what could be wrong?
Thank you.
--
Edit: Found it here: "don't confuse %Z (timezone abbr) and %z (numeric offset)"
This works:
date_obj = dt.datetime.strptime(item.pubDate.string, "%a, %d %b %Y %H:%M:%S %Z")