diff --git a/changedetectionio/blueprint/tags/templates/edit-tag.html b/changedetectionio/blueprint/tags/templates/edit-tag.html
index 1d297c81..9f316c55 100644
--- a/changedetectionio/blueprint/tags/templates/edit-tag.html
+++ b/changedetectionio/blueprint/tags/templates/edit-tag.html
@@ -63,7 +63,7 @@ xpath://body/div/span[contains(@class, 'example-class')]",
- JSONPath: Prefix with
json:
, use json:$
to force re-formatting if required, test your JSONPath here.
{% if jq_support %}
- - jq: Prefix with
jq:
and test your jq here. Using jq allows for complex filtering and processing of JSON data with built-in functions, regex, filtering, and more. See examples and documentation here.
+ - jq: Prefix with
jq:
and test your jq here. Using jq allows for complex filtering and processing of JSON data with built-in functions, regex, filtering, and more. See examples and documentation here. Prefix jqraw:
outputs the results as text instead of a JSON list.
{% else %}
- jq support not installed
{% endif %}
diff --git a/changedetectionio/html_tools.py b/changedetectionio/html_tools.py
index a03653b9..ff5cedad 100644
--- a/changedetectionio/html_tools.py
+++ b/changedetectionio/html_tools.py
@@ -3,8 +3,6 @@ from bs4 import BeautifulSoup
from inscriptis import get_text
from jsonpath_ng.ext import parse
from typing import List
-from inscriptis.css_profiles import CSS_PROFILES, HtmlElement
-from inscriptis.html_properties import Display
from inscriptis.model.config import ParserConfig
from xml.sax.saxutils import escape as xml_escape
import json
@@ -196,12 +194,12 @@ def extract_element(find='title', html_content=''):
#
def _parse_json(json_data, json_filter):
- if 'json:' in json_filter:
+ if json_filter.startswith("json:"):
jsonpath_expression = parse(json_filter.replace('json:', ''))
match = jsonpath_expression.find(json_data)
return _get_stripped_text_from_json_match(match)
- if 'jq:' in json_filter:
+ if json_filter.startswith("jq:") or json_filter.startswith("jqraw:"):
try:
import jq
@@ -209,10 +207,15 @@ def _parse_json(json_data, json_filter):
# `jq` requires full compilation in windows and so isn't generally available
raise Exception("jq not support not found")
- jq_expression = jq.compile(json_filter.replace('jq:', ''))
- match = jq_expression.input(json_data).all()
+ if json_filter.startswith("jq:"):
+ jq_expression = jq.compile(json_filter.removeprefix("jq:"))
+ match = jq_expression.input(json_data).all()
+ return _get_stripped_text_from_json_match(match)
- return _get_stripped_text_from_json_match(match)
+ if json_filter.startswith("jqraw:"):
+ jq_expression = jq.compile(json_filter.removeprefix("jqraw:"))
+ match = jq_expression.input(json_data).all()
+ return '\n'.join(str(item) for item in match)
def _get_stripped_text_from_json_match(match):
s = []
diff --git a/changedetectionio/processors/text_json_diff.py b/changedetectionio/processors/text_json_diff.py
index e89e469d..1d60be63 100644
--- a/changedetectionio/processors/text_json_diff.py
+++ b/changedetectionio/processors/text_json_diff.py
@@ -18,7 +18,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
name = 'Webpage Text/HTML, JSON and PDF changes'
description = 'Detects all text changes where possible'
-json_filter_prefixes = ['json:', 'jq:']
+json_filter_prefixes = ['json:', 'jq:', 'jqraw:']
class FilterNotFoundInResponse(ValueError):
def __init__(self, msg):
diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html
index 6d6d19fc..15cb3fd5 100644
--- a/changedetectionio/templates/edit.html
+++ b/changedetectionio/templates/edit.html
@@ -292,7 +292,7 @@ xpath://body/div/span[contains(@class, 'example-class')]",
- JSONPath: Prefix with
json:
, use json:$
to force re-formatting if required, test your JSONPath here.
{% if jq_support %}
- - jq: Prefix with
jq:
and test your jq here. Using jq allows for complex filtering and processing of JSON data with built-in functions, regex, filtering, and more. See examples and documentation here.
+ - jq: Prefix with
jq:
and test your jq here. Using jq allows for complex filtering and processing of JSON data with built-in functions, regex, filtering, and more. See examples and documentation here. Prefix jqraw:
outputs the results as text instead of a JSON list.
{% else %}
- jq support not installed
{% endif %}
diff --git a/changedetectionio/tests/test_jsonpath_jq_selector.py b/changedetectionio/tests/test_jsonpath_jq_selector.py
index 1202849f..55f46a0d 100644
--- a/changedetectionio/tests/test_jsonpath_jq_selector.py
+++ b/changedetectionio/tests/test_jsonpath_jq_selector.py
@@ -41,19 +41,26 @@ and it can also be repeated
from .. import html_tools
# See that we can find the second