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.0.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.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: greml-1.3.0.tar.gz
  • Upload date:
  • Size: 101.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for greml-1.3.0.tar.gz
Algorithm Hash digest
SHA256 66d004bc8733d2a435d2bad62c9999bd92dd0718a379dda4a7aa326e2e26ff04
MD5 4202ce36e0d77841e2f5347325edce2d
BLAKE2b-256 702e8c4d1d9d282feeffa12254d7a76c05d201f374e8551089e1b3eeaeb2fdae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: greml-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for greml-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56deeeb5a0d5d104c5093927584f5f99622eb128ccfd553b99e3c0135087b179
MD5 f69567df43b93cbd9a7e5cd870a23eba
BLAKE2b-256 ae869e8ed4a14895d2f0ad6adf6b7e4cb65f926477d6a56d8b22cd1db1462189

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