Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions shot_scraper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
BROWSERS = ("chromium", "firefox", "webkit", "chrome", "chrome-beta")




def console_log(msg):
click.echo(msg, err=True)

Expand Down Expand Up @@ -230,6 +232,7 @@ def shot(
fail,
bypass_csp,
silent,
browser_instance=None
):
"""
Take a single screenshot of a page or portion of a page.
Expand Down Expand Up @@ -278,6 +281,35 @@ def shot(
"retina": retina,
}
interactive = interactive or devtools

if browser_instance:
try:
if output == "-":
shot = take_shot(
context,
shot,
return_bytes=True,
use_existing_page=use_existing_page,
log_requests=log_requests,
log_console=log_console,
silent=silent,
)
sys.stdout.buffer.write(shot)
else:
shot["output"] = str(output)
shot = take_shot(
context,
shot,
use_existing_page=use_existing_page,
log_requests=log_requests,
log_console=log_console,
skip=skip,
fail=fail,
silent=silent,
)
except TimeoutError as e:
raise click.ClickException(str(e))

with sync_playwright() as p:
use_existing_page = False
context, browser_obj = _browser_context(
Expand Down