Skip to main content

No project description provided

Project description

Web Valueist Logo

Web Valueist

PyPI version Python versions License GitHub Issues CI Docs

Documentation Website

Fetches a value from the web, compares it with a given value and exits with zero exit code if the condition is satisfied

Table of Contents

Installation

You can install web-valueist from PyPI using your preferred package manager:

pip:

pip install web-valueist

Poetry:

poetry add web-valueist

uv:

uv pip install web-valueist

pipenv:

pipenv install web-valueist

Usage

Library

You can import and use web_valueist directly in your Python code without relying on the CLI. The evaluate function returns a generic EvaluateResult dictionary indicating whether the condition was met, along with the extracted and typed parsed values (list[int | float | str | bool]). By default, if a value fails to parse it is silently filtered out, but you can enable strict_parsing=True to instead raise a ParserError.

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"
    strict_parsing=False # Optional, defaults to False. If True, unparsable values raise ParserError.
)

if result["success"]:
    print(f"Match found! Fetched values (typed): {result['values']}")
else:
    print("Condition not met.")

CLI

web_valueist [-h] [--debug] [--json] [--strict-parsing] 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
  --strict-parsing   Raise error if a fetched value cannot be parsed instead of filtering it

Sample Usage

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

Debugging

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 --debug

Output:

DEBUG:web_valueist.lib:Found value ['245']

JSON Output

Use the --json flag to get a structured output.

python -m web_valueist http://example.com str h1 "eq" "Example Domain" --json

Output:

{"args": {"url": "http://example.com", "parser_name": "str", "quantifier": "ANY", "selector": "h1", "operator_name": "eq", "value": "Example Domain"}, "result": {"success": true, "values": ["Example Domain"]}}

Using Quantifiers

When a selector matches multiple elements, you can use ANY or EVERY.

  • ANY (default): At least one selector match needs to satisfy the condition.
  • EVERY: All selector matches need to satisfy the condition.

Example using EVERY:

python -m web_valueist https://example.com int EVERY .price ">" 100

If no quantifier is specified, ANY is used by default.

Sample cron job

*/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"; fi

Development setup from repository

While in project directory:

./install.sh

Maintainer: csmonk

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web_valueist-3.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

web_valueist-3.0.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file web_valueist-3.0.0.tar.gz.

File metadata

  • Download URL: web_valueist-3.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for web_valueist-3.0.0.tar.gz
Algorithm Hash digest
SHA256 4af8d5e43c7a710c0d8df8be9d22fc1398ccc3e0187c145a6df8bc0ca3764fbb
MD5 6717949699e0b46a4ea8e5325b832d80
BLAKE2b-256 d50a94f85ab23015c0cfae9f8b0e27575f81bd83150c370aac33e21ac5d057ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_valueist-3.0.0.tar.gz:

Publisher: pypi-publish.yml on agalazis/web-valueist

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file web_valueist-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: web_valueist-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for web_valueist-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1569e29f520f6e6513ad8907979f15c2050f9a44277b0348fc78fdd2e6befd06
MD5 862b3f219bc9f75f14e73fbccfa3fc28
BLAKE2b-256 a7dced87359f1075a03e1063eaa615e2e2142e93888ffbb36353d95643add665

See more details on using hashes here.

Provenance

The following attestation bundles were made for web_valueist-3.0.0-py3-none-any.whl:

Publisher: pypi-publish.yml on agalazis/web-valueist

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page