import urllib2 import time url = raw_input("URL: ") url += ".json" prev = 0 while True: try: response = urllib2.urlopen(url) except: break json = response.read() pos = json.find('num_comments') num = int(json[pos+15:json.find(',',pos)]) if num > prev: print "Number of comments: ", num prev = num time.sleep(1)