def process_request(self, request, spider): """ For Splash requests add 'cookies' key with current cookies to request.meta['splash']['args'] """ if 'splash' not in request.meta: return if request.meta.get('_splash_processed'): return splash_options = request.meta['splash'] splash_args = splash_options.setdefault('args', {}) if 'cookies' in splash_args: # cookies already set return if 'session_id' not in splash_options: return jar = self.jars[splash_options['session_id']] cookies = self._get_request_cookies(request) har_to_jar(jar, cookies) splash_args['cookies'] = jar_to_har(jar)
def process_request(self, request, spider): """ For Splash requests add 'cookies' key with current cookies to ``request.meta['splash']['args']`` and remove cookie headers sent to Splash itself. """ if 'splash' not in request.meta: return if request.meta.get('_splash_processed'): request.headers.pop('Cookie', None) return splash_options = request.meta['splash'] splash_args = splash_options.setdefault('args', {}) if 'cookies' in splash_args: # cookies already set return if 'session_id' not in splash_options: return jar = self.jars[splash_options['session_id']] cookies = self._get_request_cookies(request) har_to_jar(jar, cookies) splash_args['cookies'] = jar_to_har(jar) self._debug_cookie(request, spider)
def process_request(self, request, spider): """ For Splash requests add 'cookies' key with current cookies to request.meta['splash']['args'] """ if 'splash' not in request.meta: return if request.meta.get('_splash_processed'): return splash_options = request.meta['splash'] splash_args = splash_options.setdefault('args', {}) if 'cookies' in splash_args: # cookies already set return if 'session_id' not in splash_options: return jar = self.jars[splash_options['session_id']] cookies = self._get_request_cookies(request) har_to_jar(jar, cookies) splash_args['cookies'] = jar_to_har(jar) self._debug_cookie(request, spider)
def process_request(self, request, spider): """ For Splash requests add 'cookies' key with current cookies to request.meta['splash']['args'] """ if 'splash' not in request.meta: return if request.meta.get('_splash_processed'): return splash_options = request.meta['splash'] splash_args = splash_options.setdefault('args', {}) if 'cookies' in splash_args: # cookies already set return if 'session_id' not in splash_options: return _jars = self.redis_conn.get(self.redis_key) if _jars is None: self.jars = defaultdict(CookieJar) self.redis_conn.set(self.redis_key, pickle.dumps(self.jars, protocol=-1)) else: self.jars = pickle.loads(_jars) jar = self.jars[splash_options['session_id']] cookies = self._get_request_cookies(request) har_to_jar(jar, cookies) splash_args['cookies'] = jar_to_har(jar) self._debug_cookie(request, spider)