From d0e65eba7f99a91665c9a0e0e290cdb55e58e416 Mon Sep 17 00:00:00 2001 From: Ross Williams Date: Mon, 31 Jul 2023 15:34:58 -0400 Subject: [PATCH] More reliably detect Google Chrome version number Previous method was splitting on the first whitespace, and missing the version number when it appeared as `"Google Chrome 115.0.234.2342"` instead of, i.e. `"Chromium 115.0.234.8283"`. This commit changes the version detection to regex search for whitespace, then one or more digits followed by a period, then at least one more digit. Only the first sequence of digits is captured. Unless Chrome radically changes their version numbering, this should capture the first group of digits after the reported browser name, which would be the major version. --- archivebox/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/archivebox/util.py b/archivebox/util.py index a0fba9ba..daf3025e 100644 --- a/archivebox/util.py +++ b/archivebox/util.py @@ -229,7 +229,8 @@ def chrome_args(**options) -> List[str]: cmd_args = [options['CHROME_BINARY']] if options['CHROME_HEADLESS']: - if int(CHROME_VERSION.split()[1].split('.')[0]) >= 111: + chrome_major_version = int(re.search(r'\s(\d+)\.\d', CHROME_VERSION)[1]) + if chrome_major_version >= 111: cmd_args += ("--headless=new",) else: cmd_args += ('--headless',)