diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 03e318385..5397fbb0b 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -149,7 +149,7 @@ class perform_site_check(): # Inject a virtual LD+JSON price tracker rule if watch.get('track_ldjson_price_data'): - include_filters_rule.append('json:$..price') + include_filters_rule.append(html_tools.LD_JSON_PRODUCT_OFFER_SELECTOR) has_filter_rule = include_filters_rule and len("".join(include_filters_rule).strip()) has_subtractive_selectors = subtractive_selectors and len(subtractive_selectors[0].strip()) diff --git a/changedetectionio/html_tools.py b/changedetectionio/html_tools.py index 04f93f738..206be0706 100644 --- a/changedetectionio/html_tools.py +++ b/changedetectionio/html_tools.py @@ -10,6 +10,10 @@ import re # HTML added to be sure each result matching a filter (.example) gets converted to a new line by Inscriptis TEXT_FILTER_LIST_LINE_SUFFIX = "
" +# 'price' , 'lowPrice', 'highPrice' are usually under here +# all of those may or may not appear on different websites +LD_JSON_PRODUCT_OFFER_SELECTOR = "json:$..offers" + class JSONNotFound(ValueError): def __init__(self, msg): ValueError.__init__(self, msg) @@ -261,7 +265,7 @@ def html_to_text(html_content: str, render_anchor_tag_content=False) -> str: # Does LD+JSON exist with a @type=='product' and a .price set anywhere? def has_ldjson_product_info(content): try: - pricing_data = extract_json_as_string(content=content, json_filter='json:$..price', ensure_is_ldjson_info_type="product") + pricing_data = extract_json_as_string(content=content, json_filter=LD_JSON_PRODUCT_OFFER_SELECTOR, ensure_is_ldjson_info_type="product") except JSONNotFound as e: # Totally fine return False