Edit 15: I saw Javier's comment about getting just this week's top-voted threads and challenged myself to do it. I also went a little further overboard... The script will now automatically copy the output to the clipboard and send you a notification to let you know when you can paste. Should make it possible to just be a launcher for somebody to double-click.
This version requires one more dependency (xsel
for copying to the clipboard): sudo apt-get install python-beautifulsoup xsel
import urllib2, StringIO, gzip, json, time, os
from BeautifulSoup import BeautifulSoup
output = ' == Most Active Questions == \n' # (votes + answers + comments)
for q in BeautifulSoup(urllib2.urlopen('http://ubuntu.stackexchange.com/?tab=week')).findAll('h3')[:5]:
output = '%s\n * [[http://ubuntu.stackexchange.com%s|%s]]' % (output, q.contents[0]['href'], q.contents[0].string)
output = '%s\n\n == Top Voted New Questions == \n' % output # top by votes only
api_url = 'http://api.ubuntu.stackexchange.com/1.0/questions?sort=votes&order=desc&pagesize=5&fromdate=%s' % int(time.time() - 604800)
source = urllib2.urlopen(api_url).read()
for q in json.loads(gzip.GzipFile(fileobj=StringIO.StringIO(source)).read())['questions'][:5]:
output = '%s\n * [[http://ubuntu.stackexchange.com/questions/%s/|%s]]' % (output, q['question_id'], q['title'])
contribs = ['[[%s|%s]]' % (u.contents[0]['href'], u.contents[0].string) for u in BeautifulSoup(urllib2.urlopen('http://stackexchange.com/leagues/31/week/ubuntu')).findAll('h2')[1:6]]
output = '%s\n\nPeople Contributing the best questions and answers this week: %s and %s' % (output, ', '.join(contribs[0:4]), contribs[4])
print output
# Why stop there?! Let's copy this to the clipboard and spring a notification!
os.popen('xsel', 'wb').write(output)
os.system("notify-send 'Yo! When you next paste, you will be pasting the awesome scores from the Ubuntu StackExchange website.'")
Output
== Most Active Questions ==
* [[http://ubuntu.stackexchange.com/questions/3553/if-apt-get-from-2020-existed-what-one-project-would-you-install|If apt-get-from-2020 existed, what one project would you install? ]]
* [[http://ubuntu.stackexchange.com/questions/3378/my-processor-is-64-bit-does-that-mean-i-need-the-amd64-image|My processor is 64-bit - does that mean I need the amd64 image?]]
* [[http://ubuntu.stackexchange.com/questions/3541/can-not-paste-into-terminal|Can not paste into terminal]]
* [[http://ubuntu.stackexchange.com/questions/3690/linux-alternative-to-photoshop-or-paint-net|Linux Alternative to Photoshop or Paint.NET]]
* [[http://ubuntu.stackexchange.com/questions/3697/how-to-install-fonts-in-ubuntu| How to install fonts in Ubuntu?]]
== Top Voted New Questions ==
* [[http://ubuntu.stackexchange.com/questions/3554/|How to make my proxy settings change depending on the network I connect to ?]]
* [[http://ubuntu.stackexchange.com/questions/3503/|Best way to cache apt downloads on a LAN?]]
* [[http://ubuntu.stackexchange.com/questions/3530/|What's happening with windicators?]]
* [[http://ubuntu.stackexchange.com/questions/3539/|How can I make and distribute an Ubuntu screensaver?]]
* [[http://ubuntu.stackexchange.com/questions/3750/|What precautions should I take when exposing my Ubuntu desktop directly to the internet?]]
People Contributing the best questions and answers this week: [[http://ubuntu.stackexchange.com/users/449/oli|Oli]], [[http://ubuntu.stackexchange.com/users/866/fluteflute|fluteflute]], [[http://ubuntu.stackexchange.com/users/41/marco-ceppi|Marco Ceppi]], [[http://ubuntu.stackexchange.com/users/458/richard-holloway|Richard Holloway]] and [[http://ubuntu.stackexchange.com/users/235/jorge-castro|Jorge Castro]]