Last active
August 29, 2015 14:10
-
-
Save johnrc/473c9ea8f38f4e4593d7 to your computer and use it in GitHub Desktop.
Scrape melskitchencafe.com for recipes
This file contains hidden or 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
# 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