A Flutter library for extracting book data from libraccio.it product pages.
This library parses the JSON-LD structured data embedded in libraccio.it book pages and provides a convenient Dart API to access book information including title, author, ISBN, description, cover image, price, and availability.
- Extracts book data from libraccio.it product pages
- Parses JSON-LD structured data (schema.org Book/Product)
- Provides Dart models for all book properties
- Includes a widget for displaying book cover images
- Handles network requests and HTML parsing
- Automatic handling of ISBN-based lookups
- Manages HTML redirects from libraccio.it
Add this to your pubspec.yaml:
dependencies:
libraccio_extractor: ^0.1.0Then run:
flutter pub getimport 'package:libraccio_extractor/libraccio_extractor.dart';
// Extract book data by ISBN
final book = await LibraccioParser.extractBookDataByIsbn('9788806266738');
if (book != null) {
print('Title: ${book.name}');
print('Author: ${book.author?.name}');
print('Price: ${book.offers?.price} ${book.offers?.priceCurrency}');
}import 'package:libraccio_extractor/book_cover_widget.dart';
BookCoverWidget(
imageUrl: book.image,
width: 120,
height: 160,
fit: BoxFit.cover,
)The main class for extracting book data from libraccio.it.
Extracts book data from a libraccio.it product page URL.
url: The full URL of the libraccio.it product page- Returns: A
Bookobject if successful,nullotherwise
Extracts book data by ISBN from libraccio.it. This method automatically constructs the URL and handles redirects.
isbn: The ISBN of the book to look up- Returns: A
Bookobject if successful,nullotherwise
Parses book data from HTML content containing JSON-LD script tags.
htmlContent: The HTML content to parse- Returns: A
Bookobject if successful,nullotherwise
Represents a book with all its properties extracted from libraccio.it.
type: List of types (e.g., ["Book", "Product"])context: JSON-LD contextname: Title of the bookisbn: ISBN of the bookdescription: Description of the bookimage: URL of the book cover imageoffers: Offer information (see Offer model)author: Author information (see Author model)
Represents the offer information for a book.
type: Type of the offercontext: JSON-LD contextavailability: Availability statusprice: Price of the bookpriceCurrency: Currency of the price (e.g., "EUR")
Represents the author of a book.
type: Type of the authorcontext: JSON-LD contextname: Name of the author
A Flutter widget to display a book cover image with loading and error states.
imageUrl: URL of the book cover imagewidth: Width of the widget (default: 120)height: Height of the widget (default: 160)fit: How to fit the image (default: BoxFit.cover)
See the example directory for a complete Flutter app demonstrating the usage of this library.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Then run:
flutter pub getImport the library:
import 'package:libraccio_extractor/libraccio_extractor.dart';Extract book data by ISBN (recommended approach):
final book = await LibraccioParser.extractBookDataByIsbn('9788806266738');
if (book != null) {
print('Title: ${book.name}');
print('Author: ${book.author?.name}');
print('ISBN: ${book.isbn}');
print('Price: €${book.offers?.price}');
print('Availability: ${book.offers?.availability}');
}Alternatively, extract book data from a libraccio.it URL:
final book = await LibraccioParser.extractBookData(
'https://www.libraccio.it/libro/9788806266738/davide-longo/la-donna-della-mansarda.html',
);Display a book cover image:
BookCoverWidget(
imageUrl: book.image,
width: 120,
height: 160,
)Parse book data from HTML content directly:
final book = LibraccioParser.parseBookFromHtml(htmlContent);The library provides the following data models:
Book: Main book data including title, author, ISBN, description, etc.Offer: Pricing and availability informationAuthor: Author information
This library depends on:
http: For making network requestshtml: For parsing HTML contentjson_annotation: For JSON serializationcached_network_image: For efficient image loading and caching
See the example/ directory for a complete Flutter app demonstrating usage.
MIT