Merge pull request #3806 from ei-grad/disable-playwright

feat: Add --disable-playwright flag to prevent Playwright installation and prompts
This commit is contained in:
paul-gauthier 2025-05-07 17:26:00 -07:00 committed by GitHub
commit b2e3d47d14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 136 additions and 4 deletions

View file

@ -686,6 +686,12 @@ def get_parser(default_config_files, git_root):
######
group = parser.add_argument_group("Other settings")
group.add_argument(
"--disable-playwright",
action="store_true",
help="Never prompt for or attempt to install Playwright for web scraping (default: False).",
default=False,
)
group.add_argument(
"--file",
action="append",

View file

@ -220,12 +220,18 @@ class Commands:
self.io.tool_output(f"Scraping {url}...")
if not self.scraper:
res = install_playwright(self.io)
if not res:
self.io.tool_warning("Unable to initialize playwright.")
disable_playwright = getattr(self.args, "disable_playwright", False)
if disable_playwright:
res = False
else:
res = install_playwright(self.io)
if not res:
self.io.tool_warning("Unable to initialize playwright.")
self.scraper = Scraper(
print_error=self.io.tool_error, playwright_available=res, verify_ssl=self.verify_ssl
print_error=self.io.tool_error,
playwright_available=res,
verify_ssl=self.verify_ssl,
)
content = self.scraper.scrape(url) or ""