def scrape_category(response, _=None):
    schema = recipe_schema.read(response)
    category_canonical = None
    try:
        categories = schema['recipeCategory']
    except KeyError:
        logger.warning('No category found')
        return None

    for category in categories:
        category_canonical = _canonicalize_category(category)
        if category_canonical:
            break
    return category_canonical
def scrape_ingredients(response, _=None):
    return recipe_schema.read(response)['recipeIngredient']
def scrape_ingredients(response, _=None):
    ingredients_raw = recipe_schema.read(response)['ingredients']
    return _decode_ingredients(ingredients_raw)
Exemplo n.º 4
0
def scrape_published_time(response, _=None):
    schema = recipe_schema.read(response)
    return parser.parse(
        schema['datePublished']).replace(tzinfo=pytz.UTC).isoformat()