how to handle 30x when using feedparser to parse rss url
Now I am using Python 3 feedparser
to parse some RSS url, this is my code:
if __name__ == "__main__":
try:
feed = feedparser.parse("https://ucw.moe/feed/rss")
print(feed.status)
except Exception as e:
logger.error(e)
but I get this error:
HTTP Error 302: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
Found
what should I do to fix this problem?
Solution 1:
Use requests
to get the feed before like:
import requests
import feedparser
page = requests.get("https://ucw.moe/feed/rss")
print(page.status_code)
feed = feedparser.parse(page.content)