dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
16.77k stars 930 forks source link

[feature] Jinja2 template variables in POST requests #2502

Open alfablend opened 1 month ago

alfablend commented 1 month ago

Version and OS 0.45.23 on Linux/Docker

Is your feature request related to a problem? Please describe.

Variables dont work with POST requests, only with GET requests

Describe the solution you'd like

Enable to use variables in POST requests

Describe the use-case and give concrete real-world examples

I need to set date in the body of POST request to get most recent information from the site:

DateFrom={% now 'Europe/Berlin', '%d' %}.{% now 'Europe/Berlin', '%m' %}.{% now 'Europe/Berlin', '%Y' %} DateTo={% now 'Europe/Berlin', '%d' %}.{% now 'Europe/Berlin', '%m' %}.{% now 'Europe/Berlin', '%Y' %}

But this syntax doesnt work.

Additional context I can scrape the site with webdriver, but plain requests are much more faster.

dgtlmoon commented 1 month ago

Yes, well spotted, it needs something here https://github.com/dgtlmoon/changedetection.io/blob/d7e85ffe8ff07df469055e4051c23a5a8965899d/changedetectionio/processors/__init__.py#L136 reusing the "ValidateJinja2Template" and executing only in a sandbox

should probably apply to headers too!

and POST for request body test updated here https://github.com/dgtlmoon/changedetection.io/blob/d7e85ffe8ff07df469055e4051c23a5a8965899d/changedetectionio/tests/test_request.py#L120