Skip to content

Instantly share code, notes, and snippets.

@johnrc
Last active August 29, 2015 14:10
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 johnrc/473c9ea8f38f4e4593d7 to your computer and use it in GitHub Desktop.
Save johnrc/473c9ea8f38f4e4593d7 to your computer and use it in GitHub Desktop.
Scrape melskitchencafe.com for recipes
# Before running this script, install requests, beautifulsoup4
import requests as req
from bs4 import BeautifulSoup
url = "http://www.melskitchencafe.com/vanilla-buttermilk-cupcakes-and-fantastic-easy-buttercream-frosting/"
html = req.get(url)
soup = BeautifulSoup(html.text)
print "This is a recipe for: "
recipe_title = soup.find(id="zlrecipe-title").string
print(recipe_title)
print("Ingredients")
ingredients = soup.find(id="zlrecipe-ingredients-list")
for ingredient in ingredients:
# possibly save in list
# list.append(ingredient.string.rstrip())
print(ingredient.string)
print("Instructions")
instructions = soup.find(id="zlrecipe-instructions-list")
for step in instructions:
# possibly save in list
# list.append(step.string.rstrip())
print(step.string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment