hhursev / recipe-scrapers

Python package for scraping recipes data
MIT License
1.72k stars 525 forks source link

Add retrieval of reviews by using schema.org metadata #870

Closed jayaddison closed 2 weeks ago

jayaddison commented 1 year ago

Approximately 25 of the sites we retrieve data from seem to support schema.org Review metadata.

We should be able to add support for that field in the _schemaorg.py code, to provide return values from the reviews method.

See a conversation and analysis from #862 for more background.

dchoi27 commented 10 months ago

jfyi - the in-line comment and discussion here says the AllRecipes scraper implements this, but I'm not sure if that's true. I get the following

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/recipe_scrapers/plugins/schemaorg_fill.py", line 48, in decorated_method_wrapper
    return decorated(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/recipe_scrapers/_abstract.py", line 165, in reviews
    raise NotImplementedError("This should be implemented.")
NotImplementedError: This should be implemented.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.11/site-packages/recipe_scrapers/plugins/exception_handling.py", line 64, in decorated_method_wrapper
    return decorated(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/recipe_scrapers/plugins/schemaorg_fill.py", line 50, in decorated_method_wrapper
    function = getattr(self.schema, decorated.__name__)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SchemaOrg' object has no attribute 'reviews'

when running scraper.reviews() using the example in the README scraper = scrape_me('https://www.allrecipes.com/recipe/158968/spinach-and-feta-turkey-burgers/') (also tested using a few different URLs)

Thanks!

jayaddison commented 2 weeks ago

As explained in https://github.com/hhursev/recipe-scrapers/pull/1273#issuecomment-2398020007 we're not planning to implement this, so to avoid other people attempting this, I'm going to close this feature request.