Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Choose a random, acceptable keg from John's Marketplace in Portland.
from pyquery import PyQuery
import requests
from random import choice
url = ''
query = 'td table tr'
def main():
possibilities = []
resp = requests.get(url)
pq = PyQuery(resp.text)
for num, row in enumerate(pq.find(query)):
if num == 0:
continue # skip header
if len(row.getchildren()) < 5:
name = row.getchildren()[0].text
kind = row.getchildren()[5].text
if not name or 'ipa' not in name.lower():
possibilities += [name]
print choice(possibilities)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.