[foods] Add recipe website parsing
This commit is contained in:
17
scripts/README.org
Normal file
17
scripts/README.org
Normal file
@ -0,0 +1,17 @@
|
||||
#+title: Readme
|
||||
|
||||
Scripts are a collection of helpful utility scripts, or simple gut-check tests for various functional pieces.
|
||||
|
||||
* test_recipe_scraper.py
|
||||
Asserts various urls by making actual calls out to the internet, while our test suite mocks return values.
|
||||
|
||||
#+begin_src sh
|
||||
python ../manage.py shell < ../scripts/test_recipe_scraper.py
|
||||
#+end_src
|
||||
|
||||
#+RESULTS:
|
||||
| Eagerly | running | all | tasks |
|
||||
| Connected | to | sqlite@db.sqlite3 | |
|
||||
| Checking: | https://cookingwithmike.com/quinoa-meatloaf/ | | |
|
||||
| Checking: | https://www.kingarthurbaking.com/recipes/overnight-sourdough-waffles-recipe | | |
|
||||
| Checking: | https://dirt.fyi/article/2026/02/25-years-of-ipod-brain?src=longreads | | |
|
||||
21
scripts/test_recipe_scraper.py
Normal file
21
scripts/test_recipe_scraper.py
Normal file
@ -0,0 +1,21 @@
|
||||
import requests
|
||||
from foods.sources.rscraper import (
|
||||
RecipeScraperService,
|
||||
)
|
||||
|
||||
|
||||
test_urls = {
|
||||
"https://cookingwithmike.com/quinoa-meatloaf/": True,
|
||||
"https://www.kingarthurbaking.com/recipes/overnight-sourdough-waffles-recipe": True,
|
||||
"https://dirt.fyi/article/2026/02/25-years-of-ipod-brain?src=longreads": False,
|
||||
"https://tastesbetterfromscratch.com/belgian-waffles/": True,
|
||||
}
|
||||
|
||||
for k, v in test_urls.items():
|
||||
|
||||
html = requests.get(k).text
|
||||
print("Checking: ", k)
|
||||
if v:
|
||||
assert RecipeScraperService().is_recipe(html, k)
|
||||
else:
|
||||
assert not RecipeScraperService().is_recipe(html, k)
|
||||
Reference in New Issue
Block a user