You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The results (including any Python error messages) that you are seeing
I am trying to run a "wild mode" scraper on an unsupported website (ocado.com/webshop/recipe) and I just want to silence exceptions when they happen. I went through the open and close Issues, and found out that I can suppress exceptions. So I did t his:
import os
os.environ['RECIPE_SCRAPERS_SETTINGS'] = 'mealplanner.management.commands.scraper_settings'
from recipe_scrapers import scrape_me
url = 'https://ocado.com/webshop/recipe/spring-minestrone-with-kale-oil-/250826'
scraper = scrape_me(url, wild_mode=True)
scraper.cuisine()
And I get the following:
Traceback (most recent call last):
File "/home/fradeve/git/mealplanner/src/./manage.py", line 21, in <module>
main()
File "/home/fradeve/git/mealplanner/src/./manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fradeve/git/mealplanner/src/mealplanner/management/commands/populate_db.py", line 47, in handle
cuisine=scraper.cuisine(),
^^^^^^^^^^^^^^^^^
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/recipe_scrapers/_factory.py", line 45, in cuisine
return self.schema.cuisine()
^^^^^^^^^^^^^^^^^^^^^
File "/home/fradeve/.pyenv/versions/mealplanner/lib/python3.12/site-packages/recipe_scrapers/_schemaorg.py", line 292, in cuisine
raise SchemaOrgException("No cuisine data in SchemaOrg.")
recipe_scrapers._exceptions.SchemaOrgException: recipe-scrapers exception: No cuisine data in SchemaOrg.
The text was updated successfully, but these errors were encountered:
Thanks for the bugreport @fradeve! I think this is because cuisine isn't one of the methods that the exception_handling plugin handles; it will suppress exceptions for certain fields, but cuisine isn't one of them.
We might need to do some digging into the code history to figure out why that field isn't included -- the field list isn't configurable at the moment as far as I can tell.
fradeve
changed the title
Unable to silence exceptions
Unable to silence exception on "cuisine" method
Mar 13, 2024
(First and foremost, thanks for bringing us such a great piece of software!)
Pre-filing checks
The URL of the recipe(s) that are not being scraped correctly
The results you expect to see
A functional scrape, without exceptions.
The results (including any Python error messages) that you are seeing
I am trying to run a "wild mode" scraper on an unsupported website (ocado.com/webshop/recipe) and I just want to silence exceptions when they happen. I went through the open and close Issues, and found out that I can suppress exceptions. So I did t his:
scraper_settings.py
Then I used the settings like this:
And I get the following:
The text was updated successfully, but these errors were encountered: