Skip to content

Commit bea4afb

Browse files
committed
add features support
1 parent 3b3f9ae commit bea4afb

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Gerapy Auto Extractor Changelog
22

3+
## 0.0.5 (2020-07-20)
4+
5+
### Features
6+
7+
* Add support for `ignoreHTTPSErrors`, `slowMo`, `ignoreDefaultArgs`,
8+
`handleSIGINT`, `handleSIGTERM`, `handleSIGHUP`, `autoClose` args.
9+
310
## 0.0.4 (2020-07-15)
411

512
### Bug Fixes

gerapy_pyppeteer/downloadermiddlewares.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ def from_crawler(cls, crawler):
9292
cls.window_height = settings.get('GERAPY_PYPPETEER_WINDOW_HEIGHT', GERAPY_PYPPETEER_WINDOW_HEIGHT)
9393
cls.headless = settings.get('GERAPY_PYPPETEER_HEADLESS', GERAPY_PYPPETEER_HEADLESS)
9494
cls.dumpio = settings.get('GERAPY_PYPPETEER_DUMPIO', GERAPY_PYPPETEER_DUMPIO)
95+
cls.ignore_https_errors = settings.get('GERAPY_PYPPETEER_IGNORE_HTTPS_ERRORS', GERAPY_PYPPETEER_IGNORE_HTTPS_ERRORS)
96+
cls.slow_mo = settings.get('GERAPY_PYPPETEER_SLOW_MO', GERAPY_PYPPETEER_SLOW_MO)
97+
cls.ignore_default_args = settings.get('GERAPY_PYPPETEER_IGNORE_DEFAULT_ARGS', GERAPY_PYPPETEER_IGNORE_DEFAULT_ARGS)
98+
cls.handle_sigint = settings.get('GERAPY_PYPPETEER_HANDLE_SIGINT', GERAPY_PYPPETEER_HANDLE_SIGINT)
99+
cls.handle_sigterm = settings.get('GERAPY_PYPPETEER_HANDLE_SIGTERM', GERAPY_PYPPETEER_HANDLE_SIGTERM)
100+
cls.handle_sighup = settings.get('GERAPY_PYPPETEER_HANDLE_SIGHUP', GERAPY_PYPPETEER_HANDLE_SIGHUP)
101+
cls.auto_close = settings.get('GERAPY_PYPPETEER_AUTO_CLOSE', GERAPY_PYPPETEER_AUTO_CLOSE)
95102
cls.devtools = settings.get('GERAPY_PYPPETEER_DEVTOOLS', GERAPY_PYPPETEER_DEVTOOLS)
96103
cls.executable_path = settings.get('GERAPY_PYPPETEER_EXECUTABLE_PATH', GERAPY_PYPPETEER_EXECUTABLE_PATH)
97104
cls.disable_extensions = settings.get('GERAPY_PYPPETEER_DISABLE_EXTENSIONS',
@@ -128,13 +135,34 @@ async def _process_request(self, request: PyppeteerRequest, spider):
128135
f'--window-size={self.window_width},{self.window_height}',
129136
]
130137
}
131-
if self.executable_path: options['executable_path'] = self.executable_path
132-
if self.disable_extensions: options['args'].append('--disable-extensions')
133-
if self.hide_scrollbars: options['args'].append('--hide-scrollbars')
134-
if self.mute_audio: options['args'].append('--mute-audio')
135-
if self.no_sandbox: options['args'].append('--no-sandbox')
136-
if self.disable_setuid_sandbox: options['args'].append('--disable-setuid-sandbox')
137-
if self.disable_gpu: options['args'].append('--disable-gpu')
138+
if self.executable_path:
139+
options['executable_path'] = self.executable_path
140+
if self.ignore_https_errors:
141+
options['ignoreHTTPSErrors'] = self.ignore_https_errors
142+
if self.slow_mo:
143+
options['slowMo'] = self.slow_mo
144+
if self.ignore_default_args:
145+
options['ignoreDefaultArgs'] = self.ignore_default_args
146+
if self.handle_sigint:
147+
options['handleSIGINT'] = self.handle_sigint
148+
if self.handle_sigterm:
149+
options['handleSIGTERM'] = self.handle_sigterm
150+
if self.handle_sighup:
151+
options['handleSIGHUP'] = self.handle_sighup
152+
if self.auto_close:
153+
options['autoClose'] = self.auto_close
154+
if self.disable_extensions:
155+
options['args'].append('--disable-extensions')
156+
if self.hide_scrollbars:
157+
options['args'].append('--hide-scrollbars')
158+
if self.mute_audio:
159+
options['args'].append('--mute-audio')
160+
if self.no_sandbox:
161+
options['args'].append('--no-sandbox')
162+
if self.disable_setuid_sandbox:
163+
options['args'].append('--disable-setuid-sandbox')
164+
if self.disable_gpu:
165+
options['args'].append('--disable-gpu')
138166

139167
# set proxy
140168
proxy = request.proxy

gerapy_pyppeteer/settings.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,17 @@
1212

1313
# pyppeteer settings
1414
GERAPY_PYPPETEER_HEADLESS = True
15+
GERAPY_PYPPETEER_EXECUTABLE_PATH = None
16+
GERAPY_PYPPETEER_IGNORE_HTTPS_ERRORS = False
17+
GERAPY_PYPPETEER_SLOW_MO = None
18+
GERAPY_PYPPETEER_IGNORE_DEFAULT_ARGS = False
19+
GERAPY_PYPPETEER_HANDLE_SIGINT = True
20+
GERAPY_PYPPETEER_HANDLE_SIGTERM = True
21+
GERAPY_PYPPETEER_HANDLE_SIGHUP = True
1522
GERAPY_PYPPETEER_DUMPIO = False
1623
GERAPY_PYPPETEER_DEVTOOLS = False
17-
GERAPY_PYPPETEER_EXECUTABLE_PATH = None
24+
GERAPY_PYPPETEER_AUTO_CLOSE = True
25+
# pyppeteer args
1826
GERAPY_PYPPETEER_DISABLE_EXTENSIONS = True
1927
GERAPY_PYPPETEER_HIDE_SCROLLBARS = True
2028
GERAPY_PYPPETEER_MUTE_AUDIO = True

0 commit comments

Comments
 (0)