Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 1.93 KB

File metadata and controls

52 lines (39 loc) · 1.93 KB
title Dynamic Parameters
description Learn how to use dynamic parameters in URLs and headers for creating reusable feed configurations. Pass runtime values to customize feeds.

Use dynamic parameters when websites share the same structure but vary by URL or header values.

Solution

You can add dynamic parameters to the channel and headers values. This is useful for creating feeds from structurally similar pages with different URLs.

channel:
  url: "https://domainname.tld/whatever/%<id>s.html"
headers:
  X-Something: "%<foo>s"
selectors:
  items:
    selector: "article"
  title:
    selector: "h2"
  url:
    selector: "a"
    extractor: "href"

You can then pass the values for these parameters when you run html2rss:

html2rss feed the_feed_config.yml --params id:42 foo:bar

Explanation

  • The %<param>s syntax in the URL and headers is a placeholder for dynamic parameters.
  • You provide the actual values for these parameters at runtime using the --params option.
  • This allows you to reuse the same feed configuration for multiple similar pages or APIs.

Notes

  • Dynamic substitution applies to channel and headers. Selector definitions are not parameterized by this feature.
  • If a config references %<param>s and you do not provide a value, feed generation fails unless the caller supplies a fallback.
  • For shared config repositories such as html2rss-configs, it is common to store default parameter values alongside the config so examples, validation, and tests have concrete inputs.

Related Topics