'''Version 0.1'''

def autograder(url):
    '''Accepts the URL for a recipe, and returns a dictionary of the
    parsed results in the correct format. See project sheet for
    details on correct format.'''
    # your code here

    return results
@@ -1,21 +1,59 @@
-'''Version 0.1'''
+import requests%0Afrom bs4 import BeautifulSoup%0Aimport re
 %0A%0Ade
@@ -263,23 +263,999 @@
 ere%0A
-%0A    return results
+    results = %7B%7D%0A    results%5B'url'%5D = url%0A    results%5B'ingredients'%5D = %5B%5D%0A    r = requests.get(url)%0A    soup = BeautifulSoup(r.text)%0A    ingredients = soup.findAll(%22span%22, %7B %22itemprop%22 : %22ingredients%22 %7D)%0A    quantity_reg = re.compile(r'%5B%5Cd/%5D+ (?:teaspoon%7Ctablespoon%7Ccup)?s?')%0A    for ingregient_expression in ingredients:%0A    %09ingredient_dict = %7B%7D%0A    %09print ingregient_expression%0A    %09quantity = re.findall(quantity_reg, ingregient_expression.contents%5B0%5D)%0A    %09if len(quantity) %3E 1:%0A    %09%09ingredient = ingregient_expression.contents%5B0%5D.replace(quantity%5B0%5D, %22%22)%0A    %09%09ingredient_dict%5B'quantity'%5D = quantity%5B0%5D%0A    %09else:%0A    %09%09ingredient = ingregient_expression.contents%5B0%5D%0A    %09%09ingredient_dict%5B'quantity'%5D = 1%0A    %09ingredient_dict%5B'ingredient'%5D = ingredient%0A    %09print ingredient_dict%0A    %09results%5B'ingredients'%5D.append(ingredient_dict)%0A%0A    return results%0A%0Adef main():%0A%09print autograder('http://allrecipes.com/recipe/80827/easy-garlic-broiled-chicken/')%0A%0Aif __name__ == '__main__':%0A    main()

parse out ingredients and quantities from a recipe