hhursev / recipe-scrapers

Python package for scraping recipes data
MIT License
1.66k stars 514 forks source link

Store recipe link itself in object #935

Closed wassupluke closed 9 months ago

wassupluke commented 9 months ago

When using your code in my project I'm running into a situation where it would be gloriously helpful to have the link that was scraped (the link to the recipe itself) stored in the object for easier retrieval. e.g. I don't want to have to make another list just to keep track of what object belongs to what link, I want to be able to pull the link right from the object.

jayaddison commented 9 months ago

Hey @wassupluke - OK, I think I see what you mean - could you confirm that recipe.canonical_url() isn't what you're after here?

Maybe something like recipe.requested_url() would be it? (so for recipe = scrape_me(url), recipe.requested_url() == url)

wassupluke commented 9 months ago

Oh that's it! Can we add that info to the README for others to find?

jayaddison commented 9 months ago

Sure thing - done! Note that canonical_url isn't guaranteed to be available - for some websites it isn't available in the HTML. So, depending on how you're using it, and for which sites, you might be OK with that, or there could be some edge cases.