ITADN
hhursev/recipe-scrapers
hhursev/recipe-scrapers · 文件 下载 ZIP
文件最后提交记录最后更新时间
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

recipe-scrapers

.. image:: https://img.shields.io/github/stars/hhursev/recipe-scrapers?style=social :target: https://github.com/hhursev/recipe-scrapers/ :alt: Github .. image:: https://img.shields.io/pypi/v/recipe-scrapers.svg? :target: https://pypi.org/project/recipe-scrapers/ :alt: Version .. image:: https://img.shields.io/pypi/pyversions/recipe-scrapers :target: https://pypi.org/project/recipe-scrapers/ :alt: PyPI - Python Version .. image:: https://github.com/hhursev/recipe-scrapers/actions/workflows/unittests.yaml/badge.svg?branch=main :target: unittests :alt: GitHub Actions Unittests .. image:: https://coveralls.io/repos/hhursev/recipe-scraper/badge.svg?branch=main&service=github :target: https://coveralls.io/github/hhursev/recipe-scraper?branch=main :alt: Coveralls .. image:: https://img.shields.io/github/license/hhursev/recipe-scrapers? :target: https://github.com/hhursev/recipe-scrapers/blob/main/LICENSE :alt: License

快速链接

  • Documentation <https://docs.recipe-scrapers.com>_
  • Supported Sites <https://docs.recipe-scrapers.com/getting-started/supported-sites/>_
  • Contributing Guide <https://docs.recipe-scrapers.com/contributing/home/>_
  • Issue Tracker <https://github.com/hhursev/recipe-scrapers/issues>_
  • Share Project Ideas <https://github.com/hhursev/recipe-scrapers/issues/9>_

一个用于从烹饪网站提取食谱数据的 Python 包。解析来自 标准 HTML <https://developer.mozilla.org/en-US/docs/Web/HTML>_ 结构、 Schema <https://schema.org/>_ 标记(包括 JSON-LD、Microdata 和 RDFa 格式)或 OpenGraph <https://ogp.me/>_ 元数据的食谱信息。

该包提供了一个简单且一致的 API,用于获取食材、烹饪步骤、 烹饪时间和 more <https://docs.recipe-scrapers.com/contributing/in-depth-guide-scraper-functions/>_ 等数据。

兼容上述列出的 Python 版本。此包不会规避或绕过网站实施的任何 机器人保护措施。

安装

.. code:: shell

pip install recipe-scrapers

基本用法

.. code:: python

from recipe_scrapers import scrape_me

scraper = scrape_me("https://www.allrecipes.com/recipe/158968/spinach-and-feta-turkey-burgers/")
scraper.title()
scraper.instructions()
scraper.to_json()
# 完整的方法列表:
# help(scraper)

此包专注于 HTML 解析

对于高级实现,您需要自行实现获取食谱 HTML 和管理网络请求的解决方案。当您同时提供 HTML 内容和 其源域名时,该库效果最佳。

我们鼓励您使用 scrape_html 方法:

.. code:: python

from recipe_scrapers import scrape_html

当页面上有多个选项时,默认启用更高质量的图像检测。如果您希望保留网站返回的第一张图像,请 在每次调用时或通过全局设置禁用此行为:

.. code:: python

scraper = scrape_html(html, url, best_image=False)
image_url = scraper.image()

from recipe_scrapers.settings import settings

settings.BEST_IMAGE_SELECTION = False

支持的网站

我们开箱即用地支持广泛的食谱网站。请查看我们的 supported sites list <https://docs.recipe-scrapers.com/getting-started/supported-sites/>_ 以获取完整列表。

你还可以通过以下代码以编程方式获取完整列表:

.. code:: python

from recipe_scrapers import SCRAPERS

SCRAPERS.keys()

贡献

我们欢迎贡献!请阅读我们的 contribution guide <https://docs.recipe-scrapers.com/contributing/home/>_ 以开始。

特别感谢

感谢所有让该项目变得更好的 contributors <https://github.com/hhursev/recipe-scrapers/graphs/contributors>_!

.. image:: https://contrib.rocks/image?repo=hhursev/recipe-scrapers :target: https://github.com/hhursev/recipe-scrapers/graphs/contributors

分享你的项目

有关于使用 recipe-scrapers 的想法吗?查看 我们的 project ideas wall <https://github.com/hhursev/recipe-scrapers/issues/9>_ 以获取灵感 或分享你自己的项目!