0

Below is my code with the functions I have written, but I have a problem. When passing a string with the URL in the function get_feedparser('FEED_URL'), since I do not parse it well when giving me the error:

{'encoding': 'utf-8', 'bozo': 1, 'feed': {}, 'version': '', 'namespaces': {}, 'entries': [], 'bozo_exception': SAXParseException ('syntax error',)}

Any ideas on how to fix this?

def get_feedparser(FEED_URL):
    rss = feedparser.parse(FEED_URL)
    return rss

infile = open('/home/pc/Desktop/Corpus/latin_URLs.txt', 'r')

for line in infile:
    FEED_URL = line
    fp = feedparser.parse(line)
Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
  • 1
    Why are you doing `FEED_URL = line` in the loop? `UPPER_SNAKE_CASE` is usually reserved for constants. Use `lower_snake_case` for variables (and function parameters). Have you printed out each url before calling `feedparser.parse()` to see which one fails? – Bailey Parker Jan 25 '18 at 11:55
  • One of the urls you're passing to `feedparser.parse` doesn't serve a valid RSS feed. It's obviously not something you can "fix" unless you are the maintainer of the site serving this url... – bruno desthuilliers Jan 25 '18 at 13:01

0 Answers0