Skip to content

Instantly share code, notes, and snippets.

@doekman
Created July 19, 2016 11:17
Show Gist options
  • Save doekman/834a0d6a9c6e9598a42ca647462cf6da to your computer and use it in GitHub Desktop.
Save doekman/834a0d6a9c6e9598a42ca647462cf6da to your computer and use it in GitHub Desktop.
Opens one item from secretGeek's best-of-wikipedia listing in your favorite browser.
#!/usr/bin/env python3
# Tested on OS X
from lxml import html
import requests
import random
from subprocess import call
page = requests.get('http://wiki.secretgeek.net/best-of-wikipedia')
tree = html.fromstring(page.content)
links = tree.xpath('//article/ul/li/a/@href')
call(["open", random.choice(links)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment