From cc199c4e38b288acc8ec3c46bdbef255c1e4a103 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 5 Feb 2024 14:22:17 -0800 Subject: [PATCH] Just --browser-arg as argument name, refs #137, #138 --- docs/authentication.md | 2 +- docs/html.md | 2 +- docs/javascript.md | 2 +- docs/multi.md | 2 +- docs/screenshots.md | 8 ++++---- shot_scraper/cli.py | 7 ++++--- tests/run_examples.sh | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docs/authentication.md b/docs/authentication.md index b221b59..cbe16ea 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -49,7 +49,7 @@ Usage: shot-scraper auth [OPTIONS] URL CONTEXT_FILE Options: -b, --browser [chromium|firefox|webkit|chrome|chrome-beta] Which browser to use - -B, --browser-args TEXT Additional arguments to pass to the browser + --browser-arg TEXT Additional arguments to pass to the browser --user-agent TEXT User-Agent header to use --devtools Open browser DevTools --log-console Write console.log() to stderr diff --git a/docs/html.md b/docs/html.md index 78f2041..b1e2f9e 100644 --- a/docs/html.md +++ b/docs/html.md @@ -64,7 +64,7 @@ Options: --log-console Write console.log() to stderr -b, --browser [chromium|firefox|webkit|chrome|chrome-beta] Which browser to use - -B, --browser-args TEXT Additional arguments to pass to the browser + --browser-arg TEXT Additional arguments to pass to the browser --user-agent TEXT User-Agent header to use --fail Fail with an error code if a page returns an HTTP error diff --git a/docs/javascript.md b/docs/javascript.md index d6804cc..0429f28 100644 --- a/docs/javascript.md +++ b/docs/javascript.md @@ -210,7 +210,7 @@ Options: -r, --raw Output JSON strings as raw text -b, --browser [chromium|firefox|webkit|chrome|chrome-beta] Which browser to use - -B, --browser-args TEXT Additional arguments to pass to the browser + --browser-arg TEXT Additional arguments to pass to the browser --user-agent TEXT User-Agent header to use --reduced-motion Emulate 'prefers-reduced-motion' media feature --log-console Write console.log() to stderr diff --git a/docs/multi.md b/docs/multi.md index dd89111..05e5a14 100644 --- a/docs/multi.md +++ b/docs/multi.md @@ -136,7 +136,7 @@ Options: -o, --output TEXT Just take shots matching these output files -b, --browser [chromium|firefox|webkit|chrome|chrome-beta] Which browser to use - -B, --browser-args TEXT Additional arguments to pass to the browser + --browser-arg TEXT Additional arguments to pass to the browser --user-agent TEXT User-Agent header to use --reduced-motion Emulate 'prefers-reduced-motion' media feature --log-console Write console.log() to stderr diff --git a/docs/screenshots.md b/docs/screenshots.md index 24d43bd..6d2650e 100644 --- a/docs/screenshots.md +++ b/docs/screenshots.md @@ -167,12 +167,12 @@ Additional arguments to pass to the browser instance. The list of Chromium flags For example, to remove font render hinting: shot-scraper https://simonwillison.net/ -o no-hinting.png \ - --height 800 --browser-args "--font-render-hinting=none" + --height 800 --browser-arg "--font-render-hinting=none" -To add multiple arguments, add `--browser-args` for each argument: +To add multiple arguments, add `--browser-arg` for each argument: shot-scraper https://simonwillison.net/ -o no-hinting-no-gpu.png \ - --height 800 --browser-args "--font-render-hinting=none" --browser-args "--disable-gpu" + --height 800 --browser-arg "--font-render-hinting=none" --browser-arg "--disable-gpu" ## Taking screenshots of local HTML files @@ -326,7 +326,7 @@ Options: --log-console Write console.log() to stderr -b, --browser [chromium|firefox|webkit|chrome|chrome-beta] Which browser to use - -B, --browser-args TEXT Additional arguments to pass to the browser + --browser-arg TEXT Additional arguments to pass to the browser --user-agent TEXT User-Agent header to use --reduced-motion Emulate 'prefers-reduced-motion' media feature --fail Fail with an error code if a page returns an diff --git a/shot_scraper/cli.py b/shot_scraper/cli.py index a81d960..196dd2e 100644 --- a/shot_scraper/cli.py +++ b/shot_scraper/cli.py @@ -33,8 +33,7 @@ def browser_option(fn): def browser_args_option(fn): click.option( - "--browser-args", - "-B", + "--browser-arg", multiple=True, help="Additional arguments to pass to the browser", )(fn) @@ -369,7 +368,9 @@ def _browser_context( auth_username=None, auth_password=None, ): - browser_kwargs = dict(headless=not interactive, devtools=devtools, args=browser_args) + browser_kwargs = dict( + headless=not interactive, devtools=devtools, args=browser_args + ) if browser == "chromium": browser_obj = p.chromium.launch(**browser_kwargs) elif browser == "firefox": diff --git a/tests/run_examples.sh b/tests/run_examples.sh index c047208..ff56e58 100755 --- a/tests/run_examples.sh +++ b/tests/run_examples.sh @@ -85,7 +85,7 @@ shot-scraper https://shot-scraper.datasette.io/en/stable/screenshots.html \ # Add browser argument for font-render-hinting shot-scraper https://shot-scraper.datasette.io/en/stable/screenshots.html \ -w 800 -h 600 -o examples/font-hinting-none.png \ - --browser-args "--font-render-hinting=none" + --browser-arg "--font-render-hinting=none" # --wait-for echo '

Here it comes...