mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-07-26 00:05:42 -04:00
Pass headless option on Browser.__init__ and not start
We init `Browser` directly or from `BrowserPool` and we don't always call Browser.start()`. `headless` needs to be an init param and not a `start()` param.
This commit is contained in:
parent
a8f351f771
commit
f9d779133c
1 changed files with 6 additions and 4 deletions
|
@ -62,7 +62,8 @@ def check_version(chrome_exe):
|
||||||
class Chrome:
|
class Chrome:
|
||||||
logger = logging.getLogger(__module__ + '.' + __qualname__)
|
logger = logging.getLogger(__module__ + '.' + __qualname__)
|
||||||
|
|
||||||
def __init__(self, chrome_exe, port=9222, ignore_cert_errors=False):
|
def __init__(self, chrome_exe, port=9222, headless=False,
|
||||||
|
ignore_cert_errors=False):
|
||||||
'''
|
'''
|
||||||
Initializes instance of this class.
|
Initializes instance of this class.
|
||||||
|
|
||||||
|
@ -71,11 +72,13 @@ class Chrome:
|
||||||
Args:
|
Args:
|
||||||
chrome_exe: filesystem path to chrome/chromium executable
|
chrome_exe: filesystem path to chrome/chromium executable
|
||||||
port: chrome debugging protocol port (default 9222)
|
port: chrome debugging protocol port (default 9222)
|
||||||
|
headless: run in headless mode, without X windows (default: False)
|
||||||
ignore_cert_errors: configure chrome to accept all certs (default
|
ignore_cert_errors: configure chrome to accept all certs (default
|
||||||
False)
|
False)
|
||||||
'''
|
'''
|
||||||
self.port = port
|
self.port = port
|
||||||
self.chrome_exe = chrome_exe
|
self.chrome_exe = chrome_exe
|
||||||
|
self.headless = headless
|
||||||
self.ignore_cert_errors = ignore_cert_errors
|
self.ignore_cert_errors = ignore_cert_errors
|
||||||
self._shutdown = threading.Event()
|
self._shutdown = threading.Event()
|
||||||
self.chrome_process = None
|
self.chrome_process = None
|
||||||
|
@ -134,13 +137,12 @@ class Chrome:
|
||||||
cookie_location, exc_info=True)
|
cookie_location, exc_info=True)
|
||||||
return cookie_db
|
return cookie_db
|
||||||
|
|
||||||
def start(self, headless=False, proxy=None, cookie_db=None,
|
def start(self, proxy=None, cookie_db=None,
|
||||||
disk_cache_dir=None, disk_cache_size=None):
|
disk_cache_dir=None, disk_cache_size=None):
|
||||||
'''
|
'''
|
||||||
Starts chrome/chromium process.
|
Starts chrome/chromium process.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
headless: run in headless mode, without X windows (default: False)
|
|
||||||
proxy: http proxy 'host:port' (default None)
|
proxy: http proxy 'host:port' (default None)
|
||||||
cookie_db: raw bytes of chrome/chromium sqlite3 cookies database,
|
cookie_db: raw bytes of chrome/chromium sqlite3 cookies database,
|
||||||
which, if supplied, will be written to
|
which, if supplied, will be written to
|
||||||
|
@ -177,7 +179,7 @@ class Chrome:
|
||||||
'--homepage=about:blank', '--disable-direct-npapi-requests',
|
'--homepage=about:blank', '--disable-direct-npapi-requests',
|
||||||
'--disable-web-security', '--disable-notifications',
|
'--disable-web-security', '--disable-notifications',
|
||||||
'--disable-extensions', '--disable-save-password-bubble']
|
'--disable-extensions', '--disable-save-password-bubble']
|
||||||
if headless:
|
if self.headless:
|
||||||
chrome_args.append('--headless')
|
chrome_args.append('--headless')
|
||||||
if disk_cache_dir:
|
if disk_cache_dir:
|
||||||
chrome_args.append('--disk-cache-dir=%s' % disk_cache_dir)
|
chrome_args.append('--disk-cache-dir=%s' % disk_cache_dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue