1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-02 20:15:24 +02:00

Merge pull request #35 from richardmitic/scraper_fixes

Normalize recipe instructions, yield, and image url
This commit is contained in:
Hayden 2021-01-05 13:35:34 -09:00 committed by GitHub
commit 88afaa7c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1363 additions and 6 deletions

View file

@ -0,0 +1,18 @@
"""
Helper script to download raw recipe data from a URL and dump it to disk.
The resulting files can be used as test input data.
"""
import sys, json
from scrape_schema_recipe import scrape_url
for url in sys.argv[1:]:
try:
data = scrape_url(url)[0]
slug = list(filter(None, url.split("/")))[-1]
filename = f"{slug}.json"
with open(filename, "w") as f:
json.dump(data, f, indent=4, default=str)
print(f"Saved {filename}")
except Exception as e:
print(f"Error for {url}: {e}")