From b001ecb703377cacf44811cbce1ea2482c5dfaf0 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 8 Dec 2022 18:42:41 +0100 Subject: [PATCH] Price follower - handle sites with multiple ld+json tags --- changedetectionio/html_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/changedetectionio/html_tools.py b/changedetectionio/html_tools.py index 71cdc75f2..04f93f738 100644 --- a/changedetectionio/html_tools.py +++ b/changedetectionio/html_tools.py @@ -166,7 +166,9 @@ def extract_json_as_string(content, json_filter, ensure_is_ldjson_info_type=None if ensure_is_ldjson_info_type: # Could sometimes be list, string or something else random if isinstance(json_data, dict): - if json_data.get('@type', False) and json_data.get('@type','').lower() == ensure_is_ldjson_info_type.lower(): + # If it has LD JSON 'key' @type, and @type is 'product', and something was found for the search + # (Some sites have multiple of the same ld+json @type='product', but some have the review part, some have the 'price' part) + if json_data.get('@type', False) and json_data.get('@type','').lower() == ensure_is_ldjson_info_type.lower() and stripped_text_from_html: break elif stripped_text_from_html: break