Fetches a value from the web, compares it with a given value and exits with zero exit code if the condition is satisfied
You can install web-valueist from PyPI using your
preferred package manager:
pip:
pip install web-valueistPoetry:
poetry add web-valueistuv:
uv pip install web-valueistpipenv:
pipenv install web-valueistYou can import and use web_valueist directly in your
Python code without relying on the CLI. The evaluate
function returns a dictionary indicating whether the condition was met,
along with the parsed values.
import web_valueist
result = web_valueist.evaluate(
url="http://example.com",
selector="h1",
parser_name="str",
operator_name="eq",
value="Example Domain",
quantifier="ANY" # Optional, defaults to "ANY"
)
if result["success"]:
print(f"Match found! Fetched value: {result['value']}")
else:
print("Condition not met.")web_valueist [-h] [--debug] [--json] url parser_name [quantifier] selector operator_name value
positional arguments:
url
parser_name
quantifier Optional: ANY or EVERY (default: ANY)
selector
operator_name
value
options:
-h, --help show this help message and exit
--debug Show debug logs including found values
--json Output input and result as JSON
By default, web_valueist is silent and communicates
success or failure via the exit code.
Sample success
python -m web_valueist https://www.ikea.com.cy/en/products/fjallhavre-duvet-warm-240x220-cm/70458057/ int span.price__integer ">" 240( you can also use gt instead of
">")
Exit Code: 0
Sample failure
python -m web_valueist https://www.ikea.com.cy/en/products/fjallhavre-duvet-warm-240x220-cm/70458057/ int span.price__integer "<" 240( you can also use lt instead of
"<")
Exit Code: 1
Use the --debug flag to see the values fetched from the
web.
python -m web_valueist https://www.ikea.com.cy/en/products/fjallhavre-duvet-warm-240x220-cm/70458057/ int span.price__integer ">" 240 --debugOutput:
DEBUG:web_valueist.lib:Found value ['245']
Use the --json flag to get a structured output.
python -m web_valueist http://example.com str h1 "eq" "Example Domain" --jsonOutput:
{"args": {"url": "http://example.com", "parser_name": "str", "quantifier": "ANY", "selector": "h1", "operator_name": "eq", "value": "Example Domain"}, "result": {"success": true, "value": "Example Domain"}}When a selector matches multiple elements, you can use
ANY or EVERY.
Example using EVERY:
python -m web_valueist https://example.com int EVERY .price ">" 100If no quantifier is specified, ANY is used by
default.
*/30 * * * * web_valueist "https://www.bazaraki.com/car-motorbikes-boats-and-parts/cars-trucks-and-vans/mazda/mazda-mx5/year_min---71/?ordering=cheapest&lat=35.01804869361969&lng=34.04709596563199&radius=5000&price_max=30000" int .advert__content-price._not-title "<" 22500 &&message="Some fancy car matching your criteria was found" &&if command -v notify-send >/dev/null 2>&1 ; then notify-send "$message"; else say "$message"; fiWhile in project directory:
./install.shMaintainer: csmonk