3

I've been cycling through RSS feeds over the past week using feedparser. When using it today, my entire program fails to function and I've noticed that the error seems to be at the start of the program, when I'm getting the length of the feed to cycle through.

So, for instance, if I was to cycle through the BBC feed, the program goes:

import feedparser

bbc = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk')

When running this, I get absolutely no output from the code that follows. Not even an error message. Before, I'd get all the headlines on the RSS feed. This has just suddenly stopped working today. It worked for the previous week. I've tried other RSS feeds and they turn up blank too.

Any ideas as to what could be wrong?

Versace
  • 175
  • 1
  • 3
  • 11
  • Your code is working fine for me. May be there is some rate limiting? Try checking it with `curl http://feeds.bbci.co.uk/news/rss.xml?edition=uk` – Bishakh Ghosh Mar 31 '18 at 15:17
  • What do you mean by curl? I did consider rate limiting but it makes absolutely no sense. I've done this 20 times a day for a week max. Is that excessive? – Versace Mar 31 '18 at 15:18
  • Ok, so just run this python code: `import requests a = requests.get('http://feeds.bbci.co.uk/news/rss.xml?edition=uk') print(a.text)` and check the output. – Bishakh Ghosh Mar 31 '18 at 15:20
  • Ok. I'm getting the error: `ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it`. I guess my requests are being refused? I didn't think was excessive. Unless it's a change in my firewall settings etc, which I'm unaware of? – Versace Mar 31 '18 at 15:22
  • 1
    Fixed it with a bit of Googling. For some reason, my proxy settings in Internet Explorer, which I have not used in... ever... changed. That was restricting the connections, obviously runs from the settings there. – Versace Mar 31 '18 at 15:32

1 Answers1

1

You can use this code for sane error messages:

import feedparser

bbc = feedparser.parse('http://feeds.bbci.co.uk/news/rss.xml?edition=uk')
if bbc.status == 200:
    numberOfHeadlines = len(bbc['entries'])

    for i in range(0,numberOfHeadlines):
        print(bbc['entries'][i]['title'])
else:
    print("Some connection error", bbc.status)
Bishakh Ghosh
  • 1,205
  • 9
  • 17