import urllib2
from bs4 import BeautifulSoup
import datetime

class newsItem:
    def updateScore(self,score):
        self.score = score
    def __init__(self,text):
        self.text = text
        self.score = 0

def displayAllNews(news):
    for i in range(len(news)):
        print str(i+1) + ". " + news[i].text

def getNews():
    news = []
    try:
        data = urllib2.urlopen("http://www.srmuniv.ac.in").read()
        soup = BeautifulSoup(data,'html.parser')
        for tag in soup.find_all('div',{'class':'views-field views-field-title'}):
            news.append(newsItem(tag.text.strip()))
    except urllib2.URLError:
        return "fail"
    return news

def getNewNews():
    file_name = "oldnews.txt"
    obj = open(file_name)
    oldNews = obj.read().split('\n')
    news = getNews()
    if news == 'fail':
        return "fail"
    newNews = []
    for item in news:
        if item.text not in oldNews:
            newNews.append(item)
    obj.close()
    return newNews

def updateFile(newNews):
    obj = open('oldnews.txt','a')
    for item in newNews:
        obj.write(item.text + '\n')
    obj.close()

def updateLog(msg):
    '''
        -This function will update the status of the bot
         everytime it is executed. All the data goes into
         'logfile.txt'
        -This will help monitor the bot for problems.
    '''
    log = open('logfile.txt','a')
    log.write(str(datetime.datetime.now()) + " : " + str(msg) + '\n')
    log.close()

if __name__ == '__main__':
    newNews = getNewNews()
    if newNews == 'fail':
        print "Not able to reach SRM"
        updateLog("Not able to reach SRM")
    elif len(newNews) == 0:
        print "Nothing new on the website"
        updateLog("Nothing new on the website")
    else:
        displayAllNews(newNews)
        updateLog(str(len(newNews)) + " news items are new!")
    updateFile(newNews)
    raw_input() # hold

@@ -706,16 +706,17 @@
 e = %22old
+_
 news.txt
@@ -1015,32 +1015,33 @@
 ewNews):%0A    obj
+1
  = open('oldnews
@@ -1036,16 +1036,53 @@
 pen('old
+_news.txt','a')%0A    abj2 = open('new_
 news.txt
@@ -1124,16 +1124,17 @@
      obj
+1
 .write(i
@@ -1150,27 +1150,82 @@
 + '%5Cn')%0A    
+   
+ 
 obj
+2.write(item.text + '%5Cn')%0A    obj1.close()%0A    obj2
 .close()%0A%0Ade

Update srmbot.py