... because from time to time I'm a web developer, too
About me
Projects
Contact
Links

Get number of your subscribers from Feedburner

January 27, 2010 | python, tools
author: Karol Zielinski | comments: 1 | views: 1188
Tags: , , , , , ,

While we already know how to create script for getting number of followers from twitter – now it’s the best time for getting number of subscribers from feedburner. Everything will be done in python (django).

feedburner

What is Feedburner? It’s a great tool for managing RSS feeds.

Why I may want to have number of subscribers? Because we may want to show that number on our website.

We will use Feedburner’s API. What you should read is: Past Basic Feed Awareness Data

I will use XMLObject class to parse XMLs, because I simply like it.

Ok, let’s code…

Open your *.py file (it could be main/views.py) and add there one new method:

def getFeedburner(request):
    from datetime import datetime as datetime2now
	today = datetime2now.now().date()
	actTime = datetime2now.now().timetz()
	actTime = str(actTime)
	actTime = actTime[:8]
	oneDay = datetime.timedelta(days=1)
	twoDays = datetime.timedelta(days=2)
	yesterday = today - oneDay
	twodaysago = today - twoDays

	from develway.main.xmlobject import XMLFile

	url = 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=URI_OF_MY_WEBSITE&dates=' + str(twodaysago) + ',' + str(yesterday)

	f = urllib.urlopen(url)
	xml = f.read()

	xml = XMLFile(raw=xml)
	entries = xml.root.feed.entry

	circulation_yesterday = None
	circulation_twodaysago = None
	for each_entry in entries:
		if each_entry._get('date') == str(yesterday):
			circulation_yesterday = each_entry._get('circulation')
		elif each_entry._get('date') == str(twodaysago):
			circulation_twodaysago = each_entry._get('circulation')

	if circulation_yesterday:
		value = circulation_yesterday
	elif circulation_twodaysago:
		value = circulation_twodaysago

	return HttpResponse(str(value))

That’s all. Now add new view to your urls.py:

    (...)
    (r'^get-feedburner/$', 'YOUR_PROJECT.main.views.getFeedburner'),

and test it by going to the URL: http://your_domain/get-feedburner/

Everything should work fine.

Bookmark and Share
Post Get number of your subscribers from Feedburner to develway Post Get number of your subscribers from Feedburner to Delicious Post Get number of your subscribers from Feedburner to Digg Post Get number of your subscribers from Feedburner to Facebook Post Get number of your subscribers from Feedburner to Reddit Post Get number of your subscribers from Feedburner to StumbleUpon

Related news and resources

Comments (1)

4Avatars v0.3.1 v0.3.1
Liczba subskrybentów z Feedburner'a - develway.pl - wiadomości dla programistów, wiadomości IT, świeże linki ze świata IT
January 27, 2010, 4:55 am

[...] tech.karolzielinski.com Follow us on Twitter 22 śledzących RSS Feed 187 czytelników Liczba subskrybentów z Feedburner'a 1 głosuj! Tworzymy skrypt do pobierania liczby subskrybentów kanału RSS z [...]

Write a comment

Karol Zielinski :: Just a tech stuff Hello, I'm Karol Zielinski, internet evangelist, an entrepreneur, project manager and a web developer from Gdynia, Poland. I like creative design, good advertisement, social media and all kind of stuff around the web.

Most popular posts

Much more links

Karol Zielinski    |   contact me
Gdynia, Poland
RSS - Just a tech stuff - python, java blog - web development blog Karol Zielinski on twitter Karol Zielinski on LinkedIn Karol Zielinski on facebook Karol Zielinski on delicious Karol Zielinski on digg Karol Zielinski on flickr Karol Zielinski on stumbleupon Karol Zielinski on technorati