Last active
December 23, 2015 18:39
-
-
Save iffy/6677286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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