Fetch
Fetch one or more URLs. Each URL is loaded in its own page. Passing more than one URL requires --json. See how to fetch a webpage for practical documentation.
Options
usage: lightpanda fetch <url>... [OPTIONS] [COMMON_OPTIONS]
options:
--dump <DUMP>
Dumps the document to stdout.
Defaults to no dump.
Allowed values:
html Serialized HTML of the DOM.
markdown Converts content to Markdown. Asks
the server for markdown first; when
it sends some, that is dumped as-is
(logged as "markdown served"). Not
with --dump-selector, --wait-selector,
--wait-script or --inject-script,
which need the DOM.
pdf Text-only rendering of the page as a
PDF file (base64 with --json).
png Text-only rendering of the page as a
PNG image (base64 with --json).
semantic_tree JSON-serialized semantic tree.
semantic_tree_text Pruned plain-text semantic tree.
structured_data JSON-LD, OpenGraph, Twitter card, meta
and link tags as JSON.
--dump-max-bytes <INT>
Soft cap on the dumped html or markdown, in bytes. Output is cut
at a UTF-8 boundary and a '[truncated]' marker is appended.
Defaults to no cap.
--dump-selector <QUERY>
Dump only the first element matching the CSS selector instead
of the whole document. Fails if nothing matches.
--fail-on-http-error
Exit with code 22 when any page's HTTP status is 400 or above.
The dump is still written. Navigation and wait failures exit
with code 1 regardless of this flag.
Defaults to false.
--inject-script <EXPR>
JavaScript to execute as the document's <head> is parsed, before any
other scripts in the page run. Can be passed multiple times; scripts
run in order.
--inject-script-file <PATH>
Like --inject-script, but reads the script from a file. Can be passed
multiple times; can be mixed with --inject-script and runs in CLI order.
--json
Capture and print the status of the fetch as JSON. A single URL
prints one object; multiple URLs print {"results": [ ... ]} with
one object per URL. When used with --dump <MODE> the dumped
content is wrapped within each object. Each object carries an
"error" field: null, or the name of the navigation, wait or
dump failure for that URL. One failed URL does not stop the
others; the process exits 1 if any URL failed.
--markdown-alternate
With --dump markdown, when a page links a markdown version of
itself (<link rel="alternate" type="text/markdown">), dump that
file instead of converting the page. The file is the author's
and can differ from the rendered page. Falls back to converting
the page when there is no such link or it does not load as
markdown (text/markdown, or text/plain since many servers send
.md files that way). The alternate's URL is logged; with
--json, "url" is where the markdown came from. The alternate
loads within what is left of --wait-ms. Defaults to false.
--metrics
Write metrics (Prometheus text format) to stdout on exit, after
any --dump output.
Defaults to false.
--strip-mode <STRIP>
Tag group to remove from dump. Can be passed multiple times.
Defaults to stripping nothing.
Allowed values:
clutter Heuristic to keep only the main content, in the
manner of reader modes. May fallback to `shell`
(which may itself fall back to a full dump).
css Includes style and link[rel=stylesheet].
js Script and link[as=script, rel=preload].
invisible Best-effort hidden elements (e.g. display:none,
<template>).
shell Page chrome by markup: nav, aside, dialog,
page-level header and footer. Full dump when
`shell` would remove most of the text.
ui Includes img, picture, video, CSS and SVG.
--terminate-ms <INT>
Hard deadline in milliseconds. After this time elapses, JavaScript
execution is forcibly terminated (e.g. for pages with endless scripts).
Unlike --wait-ms, which only stops waiting, --terminate-ms aborts the
page.
Defaults to no terminate.
--wait-ms <INT>
Wait time in milliseconds. Supersedes all other --wait parameters.
Defaults to 5000.
--wait-script <EXPR>
Wait for a JavaScript expression to return truthy. Checked after
--wait-until condition is met.
--wait-script-file <PATH>
Like --wait-script, but reads the script from a file.
--wait-selector <QUERY>
Wait for an element matching the CSS selector to appear. Checked after
--wait-until condition is met.
--wait-until <UNTIL>
Wait until the specified event. Allowed values:
domcontentloaded The 'DOMContentLoaded' event. Often too early
for content to be reliably loaded. Pairs well
with another --wait-* (e.g. --wait-selector).
done Full quiescence, no pending scripts/network.
Polling, keepalive requests and telemetry can
hold it until --wait-ms.
load The 'load' event.
networkalmostidle At most 2 requests in flight for the last
500ms.
networkidle No network activity for the last 500ms.
settled Experimental. Waits for load, then for the
requests and short timers that page-load work
started, ignoring intervals, long timeouts,
idle callbacks and WebSocket traffic.
Resolves at load when load started nothing.
Defaults to 'load'.
If --wait-selector, --wait-script or --wait-script-file is specified,
this step is skipped unless explicitly specified. If both are
specified, this step is run first.
--with-base
Add a <base> tag in dump.
Defaults to false.
--with-frames
Includes the contents of iframes.
Defaults to false.The command also accepts the common options.