2

I'm getting addicted to Stack Overflow. I have the urge, every few minutes, to check for new questions. Is there a script that can do it for me and e-mail me, or maybe pop an alert up on my desktop whenever new questions matching my tags appear?

If there is no such script, what could be the starting point for creating one? Please suggest APIs and a sample in Python.

Obviously, the next step would be to automatically answer those questions, so I can beat Jon Skeet.

3
  • No API yet. There may never be one.
    – Kekoa
    Jun 19, 2009 at 7:13
  • if I go thru RSS feed using script after few mins does anything in SO Terms prohibit that? Jun 19, 2009 at 7:35
  • no..... why would it?
    – Shoban
    Jun 19, 2009 at 7:41

3 Answers 3

3

Here is my first attempt at such a script. Currently it prints out new questions to stdout. Maybe I will add a pluggable output class so that it can be emailed or SMSed or popped up on screen.

For example, to track Python use

$ python sofeed.py python

Here is the code.

Edit: changed getNewQuestions to generator without sleep, so it is up to the user now to delay it as he wants. It can also be embedded into any application. I added a wxPython sample application too.

import sys
import urllib2
import xml.etree.cElementTree as etree
import time
import datetime

def getQuestions(tag):
    pythonFeedURL = "http://stackoverflow.com/feeds/tag/%s"%tag
    xmlData = urllib2.urlopen(pythonFeedURL).read()

    xmlTree = etree.fromstring(xmlData)
    ns="http://www.w3.org/2005/Atom"
    questions = {}
    for i, entryElem in enumerate(xmlTree.findall("{%s}entry"%ns)):
        questions[entryElem.find('{%s}id'%ns).text] = (i, entryElem.find('{%s}title'%ns).text, entryElem.find('{%s}summary'%ns).text)

    return questions

def diffQuestions(prevQuestions, questions):
    """
    check which of the curernt questions aren't there in old set
    """
    newQuestions = []
    for qId, qData in questions.iteritems():
        if qId not in prevQuestions:
            newQuestions.append(qData)

    # sort by order in feed
    newQuestions.sort()
    return newQuestions

def getNewQuestions(tag):
    prevQuestions = {}
    while 1:
        questions = getQuestions(tag)

        newQuestions = diffQuestions(prevQuestions, questions)
        yield newQuestions

        prevQuestions = questions

def getOutputString(newQuestions):
    s = "%s new questions @ %s\n"%(len(newQuestions), datetime.datetime.now())
    for q in newQuestions:
        s += "Question: %s %s\n"%(q[0], q[1])
        s += q[2]
        s +="\n------------------------------------------------------------\n"

    return s

if __name__ == "__main__":
    tag = sys.argv[1]
    newQuestionGenerator = getNewQuestions(tag)

    useWx = 1
    if useWx:
        import wx
        app = wx.PySimpleApp()
        frame = wx.Frame(None)
        app.SetTopWindow(frame)
        timer = wx.Timer(frame)
        timer.Start(60000)
        def onTimer(evt):
            newQuestions = newQuestionGenerator.next()
            if newQuestions:
                wx.MessageBox(getOutputString(newQuestions), "New Questions")

        frame.Bind(wx.EVT_TIMER, onTimer)
        app.MainLoop()
    else:
        for newQuestions in newQuestionGenerator:
            if newQuestions:
                print getOutputString(newQuestions)
            time.sleep(1000)
1

Obviously, the next step would be to automatically answer those questions, so I can beat John Skeet

You are joking, right? ;-) No one has ever and will never beat Jon Skeet. Didn't you hear about the guy who down voted Jon Skeet's answer? Better edit your question soon before he sees it. ;-)

You can subscribe to tags and monitor the questions. I am using Snackr as my RSS reader to check it on my desktop.

I once wrote a Gmail Notifier using the RSS facility in Gmail. I am working on a similar application for Stack Overflow tags for my personal use. It's in VB.NET.

I will update here as soon as I finish it.

Alt text

1
  • nice rss is good enough Jun 19, 2009 at 7:28
0

Yes, you can get Desktop Notification for new questions on Stack Overflow.

You can see LIVE Desktop Notifier for Stack Overflow. You will get all installation details and screen shot in above link.

Note: I am the developer of this product

2
  • I understand that you want to draw attention to your app but there's a site for this, which you've already posted this on. Posting it on every tangentially related question here it could seem like you're spamming. Mar 28, 2013 at 8:00
  • I somehow cannot download this app, is there any other app for this purpose in Stackoverflow? thanks
    – Zinna
    Dec 21, 2020 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .