Skip to content

Handling variables in the watched URL

dgtlmoon edited this page Oct 24, 2022 · 10 revisions

In 1057 we add the possibility to use Jinja2 templating in the URL, using the Jinja2 time extension, you can specify a date (such as the current date according to your timezone) or a relative date (for example, the date yesterday and the date in one month)

Perfect for websites that need to search between dates, for example.

Sometimes you need to insert the current date into the requested URL, this can be done by using the Jinja2 template syntax, you can also use any other Jinja2 syntax (for example, if the day is a tuesday, then insert the word "foobar" or something)

https://changedetection.io/test.txt?date={% now 'Europe/Berlin', '%d' %}.{% now 'Europe/Berlin', '%m' %}.{% now 'Europe/Berlin', '%Y' %}

Would request (according to the Europe/Berlin) timezone

https://changedetection.io/test.txt?date=24.10.2022

List of accepted timezones https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

List of date format codes (the %d etc) https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes