Skip to main content

A CLI tool to make HTML greppable

Project description

Greml

Make HTML greppable!

A simple tool to allow you to grep HTML.

Installation

The recommended way to install is to use pipx:

pipx install greml

Usage

Specify a HTML document, either piped as stdin, or a file or HTTP request and a selector (provided by Soup Sieve).

The output may be the text of the elements, a JSON representation of the element (including all attributes) that may be parsed further using jq or the value of specific attributes.

%   greml --help

 Usage: greml [OPTIONS] [INPUT_PATH] [SELECTOR]

╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│   input_path      [INPUT_PATH]  Input file path or URL. If not specified uses stdin. [default: (stdin)]                                                           │
│   selector        [SELECTOR]    HTML selector [default: None]                                                                                                     │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --display                                          TEXT                             How to display, either 'text', 'json' or 'attr.ATTR' [default: text]          │
│ --follow-redirects        --no-follow-redirects                                     [default: follow-redirects]                                                   │
│ --user-agent                                       TEXT                             Custom User-Agent header for HTTP requests [default: None]                    │
│ --user-agent-random                                                                 Use a random User-Agent header                                                │
│ --header                                           TEXT                             Custom HTTP header in 'Header-Name: value' format [default: None]            │
│ --ajax                -a                                                            Add X-Requested-With header to simulate Ajax requests                         │
│ --timeout                                          INTEGER                          Timeout in seconds for HTTP requests [default: 30]                            │
│ --version             -v                                                                                                                                          │
│ --install-completion                               [bash|zsh|fish|powershell|pwsh]  Install completion for the specified shell. [default: None]                   │
│ --show-completion                                  [bash|zsh|fish|powershell|pwsh]  Show completion for the specified shell, to copy it or customize the          │
│                                                                                     installation.                                                                 │
│                                                                                     [default: None]                                                               │
│ --help                                                                              Show this message and exit.                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Exampless

% greml https://www.yourlifedoncaster.co.uk/trees-and-woodlands '#treeCounter'
108,000
% greml https://github.com/adamckay 'img[alt^="Achievement: "]' --display attr.alt | sort | uniq
Achievement: Arctic Code Vault Contributor
Achievement: Pull Shark
Achievement: Quickdraw
Achievement: YOLO

Custom Headers

Add custom HTTP headers to your requests using the --header option. You can specify multiple headers by repeating the option:

% greml https://api.example.com/data 'div.content' --header "Authorization: Bearer your-token"
% greml https://api.example.com/data 'div.content' --header "X-API-Key: abc123" --header "Content-Type: application/json"

Ajax Requests

Use the --ajax (or -a) option to simulate Ajax/XMLHttpRequest requests by automatically adding the X-Requested-With: XMLHttpRequest header:

% greml https://api.example.com/endpoint 'div.response' --ajax
% greml https://api.example.com/endpoint 'div.response' -a --header "Authorization: Bearer token"

This is useful when accessing APIs or web pages that behave differently for Ajax requests versus regular browser requests.

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

greml-1.3.1.tar.gz (101.4 kB view details)

Uploaded Source

Built Distribution

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

greml-1.3.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file greml-1.3.1.tar.gz.

File metadata

  • Download URL: greml-1.3.1.tar.gz
  • Upload date:
  • Size: 101.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for greml-1.3.1.tar.gz
Algorithm Hash digest
SHA256 971ca85017404d54ed35b9036fa587c2d6c3776bddce85580a8054704f8e25f0
MD5 e8fadabb3148004c773e06c574b25a33
BLAKE2b-256 21c244ffe0e4ed8265ab6aae3df39b0ed03fff969638c12cea12262f1983a620

See more details on using hashes here.

File details

Details for the file greml-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: greml-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for greml-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb35a5e1801ab6cd65a872102012ffb041b5e4419624b32d1f0a4efd0334b76
MD5 e49e0cdb13f54695e7652840b4c6895b
BLAKE2b-256 1734035ef04dc6bb68cb591bc5e1e84c06c8ef30f434e1cd49daea0100dfb621

See more details on using hashes here.

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