Class UrlToProduct

java.lang.Object
io.github.dinethdilhara.urltoproduct.core.UrlToProduct

public class UrlToProduct extends Object
UrlToProduct

A simple and extensible Java library for extracting structured product data from e-commerce URLs.

This class is the main entry point of the library. It automatically selects the best available provider (Amazon, AliExpress, Generic fallback, etc.) and returns normalized product data.

Example usage:
 UrlToProduct extractor = new UrlToProduct();
 ProductDetails product = extractor.extract("https://example.com/product/123");
 
Version:
1.0.0
Author:
Dineth Dilhara
  • Constructor Details

    • UrlToProduct

      public UrlToProduct()
      Creates a new UrlToProduct extractor instance.

      Internally loads all available product providers.

  • Method Details

    • extract

      public ProductDetails extract(String url)
      Extracts product information from the given URL.

      This method performs the following steps:

      • Selects the best matching provider
      • Extracts raw product data
      • Evaluates confidence and status
      • Returns normalized product result
      Parameters:
      url - product page URL (must be publicly accessible)
      Returns:
      extracted product details with confidence confidenceScore and status
      Throws:
      UrlToProductException - if extraction fails or URL is invalid