Dynamic Parameters
Use dynamic parameters when websites share the same structure but vary by URL or header values.
Solution
Section titled “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:barExplanation
Section titled “Explanation”- The
%<param>ssyntax in the URL and headers is a placeholder for dynamic parameters. - You provide the actual values for these parameters at runtime using the
--paramsoption. - This allows you to reuse the same feed configuration for multiple similar pages or APIs.
- Dynamic substitution applies to
channelandheaders. Selector definitions are not parameterized by this feature. - If a config references
%<param>sand 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
Section titled “Related Topics”- Custom HTTP Requests - Using dynamic parameters in headers
- Headers Reference - Complete headers documentation
- Troubleshooting - Common issues with dynamic parameters
- Advanced Features - Performance optimization tips