RSS to Tweet Python script

I was writing lots of blog posts and wanted to tweet them in regular hourly basis, So I kind of tried to follow Pomodoro technique to do this. I was tweeting them manually every hour and after a period of time I felt that why not automate this process!. It was purely for reducing a few tasks and not pumping load information. So I wrote a python script which will get the rss feed from my site and tweet it every 1 hour regularly for few post and quit. I used twitter apis and python packages feedparser and twitter for making this work. Theres a lot of improvements that can be done to this script.

$ sudo pip install feedparser
$ sudo pip install twitter

from twitter import *
import feedparser
import time

OAUTH_TOKEN = “*******************************************”
OAUTH_SECRET = “*******************************************”
CONS_KEY = “*******************************************”
CONS_SECRET = “*******************************************”

d = feedparser.parse("")
for x in range(0, 10):
    twitmessage = d.entries[x].title +" "+d.entries[x].link
    t.statuses.update( status=twitmessage)
    time.sleep(1800) # 30 minutes

For getting the tweeting part to work , you may need to checkout here.

Leave a Reply

Your email address will not be published. Required fields are marked *