(self,
url=None,
callback=None,
method='GET',
endpoint='render.html',
args=None,
splash_url=None,
slot_policy=SlotPolicy.PER_DOMAIN,
splash_headers=None,
dont_process_response=False,
dont_send_headers=False,
magic_response=True,
session_id='default',
http_status_from_error_code=True,
cache_args=None,
meta=None,
**kwargs)
| 20 | It requires SplashMiddleware to work. |
| 21 | """ |
| 22 | def __init__(self, |
| 23 | url=None, |
| 24 | callback=None, |
| 25 | method='GET', |
| 26 | endpoint='render.html', |
| 27 | args=None, |
| 28 | splash_url=None, |
| 29 | slot_policy=SlotPolicy.PER_DOMAIN, |
| 30 | splash_headers=None, |
| 31 | dont_process_response=False, |
| 32 | dont_send_headers=False, |
| 33 | magic_response=True, |
| 34 | session_id='default', |
| 35 | http_status_from_error_code=True, |
| 36 | cache_args=None, |
| 37 | meta=None, |
| 38 | **kwargs): |
| 39 | |
| 40 | if url is None: |
| 41 | url = 'about:blank' |
| 42 | url = to_native_str(url) |
| 43 | |
| 44 | meta = copy.deepcopy(meta) or {} |
| 45 | splash_meta = meta.setdefault('splash', {}) |
| 46 | splash_meta.setdefault('endpoint', endpoint) |
| 47 | splash_meta.setdefault('slot_policy', slot_policy) |
| 48 | if splash_url is not None: |
| 49 | splash_meta['splash_url'] = splash_url |
| 50 | if splash_headers is not None: |
| 51 | splash_meta['splash_headers'] = splash_headers |
| 52 | if dont_process_response: |
| 53 | splash_meta['dont_process_response'] = True |
| 54 | else: |
| 55 | splash_meta.setdefault('magic_response', magic_response) |
| 56 | if dont_send_headers: |
| 57 | splash_meta['dont_send_headers'] = True |
| 58 | if http_status_from_error_code: |
| 59 | splash_meta['http_status_from_error_code'] = True |
| 60 | if cache_args is not None: |
| 61 | splash_meta['cache_args'] = cache_args |
| 62 | |
| 63 | if session_id is not None: |
| 64 | if splash_meta['endpoint'].strip('/') == 'execute': |
| 65 | splash_meta.setdefault('session_id', session_id) |
| 66 | |
| 67 | _args = {'url': url} # put URL to args in order to preserve #fragment |
| 68 | _args.update(args or {}) |
| 69 | _args.update(splash_meta.get('args', {})) |
| 70 | splash_meta['args'] = _args |
| 71 | |
| 72 | # This is not strictly required, but it strengthens Splash |
| 73 | # requests against AjaxCrawlMiddleware |
| 74 | meta['ajax_crawlable'] = True |
| 75 | |
| 76 | super(SplashRequest, self).__init__(url, callback, method, meta=meta, |
| 77 | **kwargs) |
| 78 | |
| 79 | @property |
no test coverage detected