Crates.io | recipe-scraper |
lib.rs | recipe-scraper |
version | 0.1.0 |
source | src |
created_at | 2024-11-24 23:49:35.559121 |
updated_at | 2024-11-24 23:49:35.559121 |
description | A library for parsing structured recipes from the web |
homepage | |
repository | https://github.com/torrancew/recipe-scraper |
max_upload_size | |
id | 1459739 |
size | 18,770 |
recipe-scraper
is a Rust library for scraping structured recipe data from the web
It provides a simple set of APIs to find and parse compliant recipe formats
recipe-scraper
is fairly pragmatic, and extracts minimal data from recipes. It currently extracts the following (meta-)data:
And supports the following structured recipe formats:
recipe-scraper
provides methods that operate on HTML strings, as well as directly on JSON. It explicitly does not provide HTTP client functionality.
Scraping a recipe from an HTML string (which can be obtained via reqwest
or ureq
, etc):
use recipe_scraper::{
Extract,
Scrape,
SchemaOrgEntry,
SchemaOrgRecipe,
};
// let html = ...;
let schema_entries = SchemaOrgEntry::scrape_html(&html);
if let Some(first_valid_recipe) = schema_entries.into_iter().flat_map(Extract::extract_recipes).next() {
println!("Found recipe!: {first_valid_recipe:?}")
}