Ever since I’ve moved to my own server for my websites, I’ve wanted to reduce the number of HTTP requests per user as much as possible. Here is how I (and you) can use Python to shave 1 more request off that number.
I can do this (and remove a DNS lookup) by updating my Feedburner count using an automated script on my server instead of having each client request it.
Using the FeedBurner Awareness API
Most of the time you only care about getting your total subscribers at the moment. The FeedBurner Awareness API is far more capable than just doing that, but we’re going to keep it simple today.
For the simple case you just need your feed ID or URI. Try:
You receive an XML response like:
Now we just need to parse out the “circulation” which is your subscriber count.
Quick and dirty bash script
This is what I used to use until FeedBurner started returning 0s or blanks in the XML returned:
You can use cron to replace some HTML, log the count, etc. every so often.
The Python
The Python version is much lengthier but has error checking and does not have to do file-replacement. The following is also available on GitHub for your extending pleasure ;).
Something like this would be especially cool if you could set thresholds or use optparse for advanced options. Useful? Hope so!