Expand description
§Goodreads Metadata Scraper
This library provides a convenient way to fetch and scrape book metadata from Goodreads by providing either an ISBN, a Goodreads book ID, or a combination of title and author. It is designed to be used in applications where access to Goodreads book data is needed, but no official Goodreads API access is available.
§Features
- Retrieve metadata by ISBN
- Retrieve metadata by Goodreads ID
- Retrieve metadata by title (optionally with author for more accurate results)
- Structured, typed metadata output for easy access to common book fields (title, author, publication year, etc.)
- Query builder pattern for customizable requests
§Usage
Add this crate to your dependencies in Cargo.toml
:
[dependencies]
goodreads-metadata-scraper = "0.2.1"
§Examples
To use this library, create a MetadataRequestBuilder
to specify the search criteria. Then, use
the execute
method to retrieve the metadata.
§Fetching Metadata by ISBN
use grscraper::MetadataRequestBuilder;
let isbn = "9780141381473";
let metadata = MetadataRequestBuilder::default()
.with_isbn(isbn)
.execute()
.await?
.expect("Book not found");
assert_eq!(metadata.title, "The Lightning Thief");
println!("{:#?}", metadata);
§Fetching Metadata by Goodreads ID
use grscraper::MetadataRequestBuilder;
let goodreads_id = "175254";
let metadata = MetadataRequestBuilder::default()
.with_id(goodreads_id)
.execute()
.await?
.expect("Book not found");
assert_eq!(metadata.title, "Pride and Prejudice");
println!("{:#?}", metadata);
§Fetching Metadata by Title and Author
Providing an author along with the title helps improve the accuracy of the search:
use grscraper::MetadataRequestBuilder;
let title = "The Last Magician";
let author = "Lisa Maxwell";
let metadata = MetadataRequestBuilder::default()
.with_title(title)
.with_author(author)
.execute()
.await?
.expect("Book not found");
assert_eq!(metadata.title, title);
println!("{:#?}", metadata);
§Limitations
- Since this library relies on web scraping, it may be sensitive to changes in Goodreads’ website structure.
- This library is intended for personal or small-scale use, as frequent requests to Goodreads may be rate-limited.
Note: When running tests, it is highly recommended to run them with the --test-threads=1
flag to avoid rate-limiting issues with Goodreads.
§License
This project is licensed under the GNU General Public License (GPL).
Structs§
- Book
Contributor - Represents an individual who contributed to the book, such as an author or editor.
- Book
Metadata - The primary data structure containing the metadata of a book.
- Book
Series - Represents series information for a book, including the series title and book’s position within the series.
- Metadata
Request Builder - Builder for constructing a metadata request.
Enums§
- Scraper
Error - Custom error type for handling errors in the Goodreads metadata scraper.