September 17, 2010

  • Those Guys

    I think my job is turning me into one of "those guys". Some of you might know what I mean. One of "those guys" that spend all day at work writing computer code, then going home only to do more coding. For example, I just spent the last few minutes writing a script that trawls an RSS feed for updates with a specific string every five minutes. Why? Well, I would tell you the truth, but I think it'd be more entertaining to let your imagination go wild. If you want it, the code is below (it's Python, by the way):


    import urllib
    import sys
    import time
    from datetime import datetime

    url = sys.argv[1]
    thing = raw_input('What do you seek: ')
    lastDate = ''
    while True:
      try: f = urllib.urlopen(url)
      except (IOError): continue
      body = f.read()
      lines = body.split('n')
      for line in lines:
         if line.strip().startswith('<pubDate>'):
             curDate = line.split('>')[1].split('<')[0]
             if curDate == lastDate:
                break
             else:
                if thing in body:
                   print "OMG! %s has been found!" % thing
                   sys.exit(1)
                else:
                   print "There's an update, but it's probably nothing special"
                   lastDate = curDate
                   break
      f.close()
      print "%s -- %s" % (lastDate, str(datetime.now()))
      time.sleep(300)

Comments (3)

  • This code snippet will be utilized for many... important... news stories.

  • So your turning into my father?
     Look around if you have a pile of unopen/unplayed video games, an unused exercise machine, a pile of books about computer programing, and or massive amounts of two buck chuck then you are turning into that guy. 

  • I have no idea what to do with this information.  It's lovely?

Post a Comment

Leave a Reply

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