[Tutor] feedparser in python
Alan Gauld
alan.gauld at yahoo.co.uk
Mon Apr 29 03:43:10 EDT 2019
On 29/04/2019 01:26, nathan tech wrote:
> Most recently, I have started work using feedparser.
I've never heard of it let alone used it so there may
be another forum where you can get specific answers.
But let me ask...
> I noticed, almost straight away, it's a bit slow.
How do you measure slow? What speed did you expect?
What other xml parsers have you tried? etree for example?
How much faster was it compared to feedparser?
> For instance:
>
> url="http://feeds.bbci.co.uk/news/rss.xml"
> f1=feedparser.parse(url)
So it looks like the parer is doing more than just
parsing it is also fetching the data over the net.
How long does that take? Could it be a slow connection
or server?
Can you try parsing a feed stored on the local
machine to eliminate that portion of the work?
Is it much faster? If so its the network causing the issue.
> On some feeds, this can take a few seconds, on the talk python to me
> feed, it takes almost 10!
How big is the feed? If its many megabytes then 10s might
not be too bad.
> This, obviously, is not ideal when running a program which checks for
> updates every once in a while. Talk about slooooow!
When I talk about "sloooooow" I'm thinking about
something that takes a long time relative to how long
it would take me manually. If downloading and parsing
these feeds by hand would take you 5 minutes per feed
then 10s is quite fast...
But if parsing by hand takes 30s then 10s would indeed
be sloooow.
> Similarly, this doesn't seem to work:
>
> f2=feedparser.parse(url, f.headers["date"])
define "doesn't work"?
Does the PC crash? Does it not fetch the data?
Does it fail to find "date"?
Do you get an error message - if so what?
> What am I doing wrong?
No idea, you haven't given us enough information.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list