Skip to content

Instantly share code, notes, and snippets.

@iffy
Last active December 23, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iffy/6677286 to your computer and use it in GitHub Desktop.
Save iffy/6677286 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
page = requests.get('http://www.eastbaycafe.com/menu.php')
the_html = BeautifulSoup(page.text)
mapping = {
'soup': 'steam',
'flavor': 'flavor',
'main': 'mainevent',
'greens': 'fieldofgreens',
'grill': 'dailygrill',
}
stations = {}
main_div = the_html.find_all('div', 'menu_content')[0]
# Get the data and assign it to the correct station
# start with the soup... there is probably a better way to do this than all
# these try catch blocks
for k,v in mapping.items():
try:
stations[k] = main_div.find_all('li', v)[0].contents[2]
except:
pass
print stations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment