dgtlmoon/changedetection.io

[feature] regex substitution for each line of result

Opened this issue · 4 comments

Discussed in #2652

Originally posted by brunetton September 21, 2024
Version and OS
v0.46.04 / Docker

Is your feature request related to a problem? Please describe.
Yes: I'm trying to extract a list of links from a list from this page. I'm using an XPath expression like this:

//div[@id="js-default-offers"]//a[contains(@class,"js-offer-link-item")]/@href

Then I'm using an SMS API to send those links via SMS.

This principle works well for 2 other websites, but I'm trying to achieve it for a website that have relative links. The output from the XPath expression is:

/magasins/la-foir-fouille/offres/tapis-diatomite-offre-43076750/
/magasins/la-foir-fouille/offres/tapis-diatomite-offre-43076805/

I'd like to make links clickable from my Android device from received SMS. For this I'd need to add the domain name in the beginning of each link, to have something like:

https://www.promocatalogues.fr/magasins/la-foir-fouille/offres/tapis-diatomite-offre-43076750/
https://www.promocatalogues.fr/magasins/la-foir-fouille/offres/tapis-diatomite-offre-43076805/

As far as I know, I can't add string to each result (concat() only works for one element).

Describe the solution you'd like
I'd like to be able to apply a substitution regex to each result line, like if I'm using sed applied to the output.

This is more generic than the existing "Extract text" section of "filters-and-triggers" page and could replace it (?)

Describe the use-case and give concrete real-world examples
This is not really related to any example, but I gave an example above

Thank you !

We need some kind of filter like "Rewrite output"

@brunetton can you do this..

{% set lines = diff.splitlines() %}

{% for line in lines %}
  https://google.com/{{ line }}<br>
{% endfor %}

in notifcation template body? that should work

@brunetton can you do this..

{% set lines = diff.splitlines() %}

{% for line in lines %}
  https://google.com/{{ line }}<br>
{% endfor %}

in notifcation template body? that should work

Ow yes of course ! I didn't thought about that but you're 100% right :)

Thank you for this super-quick answer.

Maybe would it be "cleaner" to be able to achieve it in the "Filters & Triggers" section, to have complete URLs in history, but yeah, it works :)

related #2000