Preparing search index...

    Recipe scraper class providing access to recipe scraping.

    This class wraps the platform-specific implementation and provides type-safe result handling. Supported on Android, iOS, and Web.

    Index

    Constructors

    Methods

    • Scrapes a recipe from a URL.

      Parameters

      • url: string

        The recipe page URL to scrape.

      • Optionaloptions: ScrapeOptions

        Optional scraping options.

      Returns Promise<ScraperResult>

      A result object with either the scraped recipe data or an error.

      const result = await scraper.scrapeRecipe('https://allrecipes.com/recipe/...');
      if (result.success) {
      console.log(result.data.title);
      console.log(result.data.ingredients);
      } else {
      console.error(result.error.message);
      }
    • Scrapes a recipe from HTML content.

      Useful when you've already fetched the HTML yourself and want to avoid an additional network request.

      Parameters

      • html: string

        The HTML content of the recipe page.

      • url: string

        The original URL (used for host detection and relative URLs).

      • Optionaloptions: ScrapeOptions

        Optional scraping options.

      Returns Promise<ScraperResult>

      A result object with either the scraped recipe data or an error.

    • Scrapes a recipe from an authentication-protected URL.

      Logs into the site using provided credentials and scrapes the recipe.

      • Android: Uses Python requests.Session via Chaquopy.
      • iOS: Navigates a hidden WKWebView to the login page, then injects a same-origin JavaScript script that performs the full auth flow using WebKit's own cookie jar (WKHTTPCookieStore). The fetched recipe HTML is then parsed by Pyodide. Returns an error on unsupported platforms or unsupported auth hosts.

      Parameters

      • url: string

        The recipe page URL to scrape.

      • username: string

        Username/email for authentication.

      • password: string

        Password for authentication.

      • Optionaloptions: ScrapeOptions

        Optional scraping options.

      Returns Promise<ScraperResult>

      A result object with either the scraped recipe data or an error.

    • Checks if the Python runtime is ready for scraping.

      On Android, returns true once Chaquopy Python has finished initializing. On iOS, returns true once Pyodide WebView has finished loading. On Web, this always returns true (no Python needed).

      Returns Promise<boolean>

      true if ready, false if still initializing.

    • Waits for Python to be ready for scraping.

      Call this during app initialization to ensure Python is loaded before allowing users to access web parsing features.

      Parameters

      • timeoutMs: number = 30000

        Maximum time to wait (default: 30000ms)

      • pollIntervalMs: number = 100

        Time between checks (default: 100ms)

      Returns Promise<boolean>

      true if ready, false if timeout reached