Skip to content

Commit

Permalink
Just --browser-arg as argument name, refs #137, #138
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Feb 5, 2024
1 parent 3df5fa0 commit cc199c4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/multi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docs/screenshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions shot_scraper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion tests/run_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<html>
<body><h1>Here it comes...</h1>
Expand Down

0 comments on commit cc199c4

Please sign in to comment.