Skip to content

CLI Reference

This page documents the html2rss command-line interface (CLI).

For detailed documentation on the Ruby API, please refer to the official YARD documentation.

📚 View the Ruby API Docs on rubydoc.info

The html2rss executable is the primary way to interact with the gem from your terminal.

Automatically discovers items from a page and prints the generated RSS or JSONFeed to stdout.

Terminal window
html2rss auto https://example.com/articles ; \
html2rss auto https://example.com/articles --format jsonfeed ; \
html2rss auto https://example.com/articles --limit 10 ; \
BOTASAURUS_SCRAPER_URL="http://localhost:4010" html2rss auto https://example.com/protected --strategy botasaurus ; \
html2rss auto https://example.com/articles --items_selector ".post-card" ; \
html2rss auto https://example.com/articles --explain ; \
html2rss auto --input sample.html ; \
html2rss auto https://example.com/articles --input sample.html

Command: html2rss auto [URL]

Available options:

  • --strategy: Optional request strategy (auto, faraday, botasaurus, local_file). Defaults to auto, which tries faraday -> botasaurus.
  • --format: Output format for the auto-sourced feed (rss or jsonfeed). Defaults to rss.
  • --limit: Maximum number of articles to extract during discovery (defaults to 25).
  • --items_selector: Optional CSS selector hint for item extraction.
  • --max-redirects: Maximum redirects to follow per request.
  • --max-requests: Maximum requests to allow for this feed build (defaults to 4 for auto discovery).
  • --input: Local HTML file path to read input from without making network requests. When provided without a URL, html2rss attempts to detect the base URL from <link rel="canonical"> or OpenGraph metadata in the HTML.
  • --explain: Print Html2rss::Status JSON to stderr (version, dedup_dropped, and when present scraper_tallies, selected_strategy, attempt_count, strategy_attempts, admission_drops, entry_url, scrape_url, entry_resolution). Stdout stays the RSS or JSON Feed.

auto works best when the input URL already exposes a server-rendered list of entries.

  • High-success surfaces:
    • newsroom or press listing pages
    • blog/category/tag listing pages
    • changelog/release notes/update listing pages
    • paginated archive/list views
  • Low-success surfaces:
    • generic homepages with heavy promo/navigation chrome
    • search results pages
    • client-rendered app shells (#app, #root, #__next, etc.)

When possible, pass a direct listing/update URL instead of a top-level homepage or app entrypoint.

When no extractable items are found, auto classifies likely causes instead of only returning a generic message:

  • blocked surface likely (anti-bot or interstitial):
    • try a more specific public listing URL or configure BOTASAURUS_SCRAPER_URL
  • app-shell surface detected:
    • switch to a direct listing/update URL or configure BOTASAURUS_SCRAPER_URL
  • unsupported extraction surface for auto mode:
    • switch to listing/changelog/category URLs
    • use explicit selectors in a feed config

Known anti-bot interstitial responses (for example Cloudflare challenge pages) are surfaced explicitly as blocked-surface errors.

If all fallback tiers run but still extract zero items, html2rss raises:

  • No RSS feed items extracted after auto fallback ...

If failures continue after URL/surface fixes, ensure BOTASAURUS_SCRAPER_URL is set so the auto Botasaurus tier can run.

Start by changing the input URL to a direct listing/update page, then move to explicit selectors if needed.

botasaurus is an explicit strategy option for CLI usage and requires BOTASAURUS_SCRAPER_URL:

Terminal window
BOTASAURUS_SCRAPER_URL="http://localhost:4010" \
html2rss auto https://example.com/updates --strategy botasaurus

If you see a Botasaurus configuration error, check:

  • BOTASAURUS_SCRAPER_URL is set
  • BOTASAURUS_SCRAPER_URL is a valid URL
  • the Botasaurus scrape API is reachable from the shell environment running html2rss

Loads a YAML config, builds the feed, and prints the RSS XML to stdout.

Terminal window
html2rss feed single.yml ; \
html2rss feed feeds.yml my-first-feed ; \
html2rss feed single.yml --strategy auto ; \
BOTASAURUS_SCRAPER_URL="http://localhost:4010" html2rss feed single.yml --strategy botasaurus ; \
html2rss feed single.yml --max-redirects 5 --max-requests 6 ; \
html2rss feed single.yml --params id:42 foo:bar ; \
html2rss feed single.yml --input sample.html

Command: html2rss feed YAML_FILE [feed_name]

Available options:

  • --strategy: Request strategy override (auto, faraday, botasaurus, local_file).
  • --params: Dynamic parameters passed as key-value pairs (e.g. --params id:42 section:news).
  • --max-redirects: Maximum redirects to follow per request.
  • --max-requests: Total request budget allowed for this feed build.
  • --input: Local HTML file path to read input from instead of making a network request.

The CLI keeps strategy as a top-level override and writes runtime request limits into the generated config under request.

Analyzes a URL using auto-source structural analysis and prints a reusable YAML feed configuration (items selector + enhance: true) to stdout.

Terminal window
html2rss capture https://example.com/articles ; \
html2rss capture https://example.com/articles --strategy botasaurus ; \
html2rss capture https://example.com/articles --items_selector ".post-card" ; \
html2rss capture https://example.com/articles --explain ; \
html2rss capture --input sample.html

Command: html2rss capture [URL]

Available options:

  • --strategy: Optional request strategy (auto, faraday, botasaurus, local_file). Defaults to auto.
  • --items_selector: Optional CSS selector hint for item extraction.
  • --limit: Maximum number of articles to keep (defaults to 25).
  • --max-redirects: Maximum redirects to follow per request.
  • --max-requests: Maximum requests to allow for this feed build.
  • --input: Local HTML file path to read input from without making network requests.
  • --explain: Print capture quality JSON to stderr (articles_count, channel_title, has_selectors, segment_strategy, selected_strategy, admission_drops). Stdout stays YAML.

When AutoFallback (or a pinned strategy) selects a concrete transport, the printed YAML includes a top-level strategy: so later html2rss feed uses the same hop.

Starts the Model Context Protocol (MCP) server for integration with AI clients and agent workflows (Cursor, Claude Desktop, Copilot).

Terminal window
html2rss mcp ; \
html2rss mcp --transport stdio ; \
html2rss mcp --transport http --port 8080

Command: html2rss mcp

Available options:

  • --transport: MCP transport protocol (stdio or http). Defaults to stdio.
  • --port: Port for HTTP transport (default: 8080). Bound strictly to 127.0.0.1 (loopback only).

HTTP transport requires the rack, rackup, and webrick gems. MCP daemon logging (stderr, LOG_LEVEL) is documented in the MCP Server Reference. See also the AI Agent Workflows Guide for client setup and tool schemas.

Prints or writes the exported JSON Schema for the current gem version.

Terminal window
html2rss schema ; \
html2rss schema --no-pretty ; \
html2rss schema --write tmp/html2rss-config.schema.json

Command: html2rss schema

Available options:

  • --pretty / --no-pretty: Pretty-print the schema JSON (default: true).
  • --write PATH: Write the schema JSON directly to the given file path, creating any missing parent directories.

Validates a config with the runtime validator without generating a feed.

Terminal window
html2rss validate single.yml ; \
html2rss validate feeds.yml my-first-feed ; \
html2rss validate single.yml --params id:42

Command: html2rss validate YAML_FILE [feed_name]

Available options:

  • --params: Dynamic parameters to interpolate before validation (default: {}).

Displays the help message with available commands and options.

Command: html2rss help

Displays the installed version of html2rss.

Command: html2rss --version