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.69k stars 924 forks source link

[feature] Price Threshold Filter #879

Open jrruethe opened 2 years ago

jrruethe commented 2 years ago

Version and OS Docker image dgtlmoon/changedetection.io:0.39.18

Is your feature request related to a problem? Please describe. ChangeDetection.io does a great job extracting text and creating notifications when that text changes. However, from what I can tell, it cannot interpret the extracted text of something like a price as a number and trigger a notification when that number exceeds a threshold.

Describe the solution you'd like Underneath the "Extract Text" options in "Filters & Triggers", I'd like to see a checkbox such as "Extracted Text is a Number", followed by a way to set a trigger if that number is <, =, > a value. For example, the trigger fires if the extracted price is < 20.

Describe the use-case and give concrete real-world examples As an example, I'd like to use ChangeDetection.io to monitor when the Bitcoin price exceeds a value.

So using this site: https://coinmarketcap.com/currencies/bitcoin/

With this XPath filter: /html/body/div[1]/div/div[1]/div[2]/div/div[1]/div[2]/div/div[2]/div[1]/div/span

And this regex under "Extract Text": \$([0-9,.]+)

I can extract the current Bitcoin price (which at the time of this writing is 21,582.35). This works well, I have pulled out the price as a number without the dollar sign.

However, the Bitcoin price changes quite often, by small amounts, which normally causes this notification to fire on each check. In reality, I only really care if the price has risen above some value (or dropped below some value). In this example, maybe I want to set the threshold to 22,000.00 and only trigger a notification if the extracted value exceeds that threshold.

This would essentially suppress all the notifications from the price fluctuations, but still notify me if there is a large change.

I suppose if the price does go above the threshold, it would then trigger a notification with each little fluctuation, which is fine.

As another use-case example, Amazon prices tend to fluctuate. Maybe I want to set a watch for an item that is normally around $20, and be notified if that price drops below $15. I don't need to be notified if the price goes to $19 or up to $25.

Additional context If this is already possible, I was unable to find the documentation for it. Thanks!

bmn001 commented 1 year ago

I just discovered this project, and this feature request is my primary use case - notify me when things go on sale or when items are mis-priced below a threshold. +1 on this request.

masterwishx commented 1 year ago

Sorry, I don't get it. Can we use conditions at now and how we do it?

dgtlmoon commented 1 year ago

no, i'm open to a pull-request if you want to add it

masterwishx commented 1 year ago

no, i'm open to a pull-request if you want to add it

Thanks a lot, very like your app

dgtlmoon commented 1 year ago

An idea, could be some language to describe a trigger filter like

math: extract_any_number_value > 10.50

which goes in the trigger text setting

dgtlmoon commented 1 year ago

Duplicate #190

timmeh-git commented 1 year ago

+1 for this feature. This is such a fantastic project and I appreciate all the work being put into it. The lack of a threshold filter is the only part that is really limiting its use for me.

codedesperate commented 11 months ago

I'd really like this as well. Currently I'm using regex filter under the "Trigger/wait for text" section. But regex and number ranges is a mess. And it doesn't work in all scenarios.

I too use a xpath selector that gives me just the value. Even the functionality to execute an external script on a trigger would be great. Then we could make our own condition scripts.

codedesperate commented 11 months ago

I found a way to do this! Or rather, I found a comment here from someone who found the way! https://github.com/dgtlmoon/changedetection.io/discussions/1474#discussioncomment-6652576

Using XPATH, I can now have price alerts that should only alert when under a specific threshold. One caveat though, is while as long as the price is not under the specified value, changedetection will report: Warning, no filters were found, no change detection ran - Did the page change layout? update your Visual Filter if necessary. Because the filter will only match when the price is under. I now have price monitors with prices written as "9999" and "9.999" as sudlon in this comment also showed how to deal with dots and commas. For a 9.999 price I just strip the "." away so it will compare with 9999.

pauljones0 commented 3 months ago

Building on this, to get rid of the dollar sign, comma and periods, use this XPATH filter:

/html/body/div[3]/div[4]/section/section/div[6]/div[2]/div[2]/div[1]/div/div/div[number(translate(text(), '$,.', '')) < 129999]

This does the logic on the XPATH of: /html/body/div[3]/div[4]/section/section/div[6]/div[2]/div[2]/div[1]/div/div/div