From 68c17c3fbcc20b9e63a3b97d0faac092a970dd10 Mon Sep 17 00:00:00 2001 From: Jean-Louis Huynen Date: Thu, 31 Aug 2023 16:13:20 +0200 Subject: [PATCH] chg: [crawlers] submit cookies to the crawler task API --- bin/lib/crawlers.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/lib/crawlers.py b/bin/lib/crawlers.py index 3a0a9f19..67f868f0 100755 --- a/bin/lib/crawlers.py +++ b/bin/lib/crawlers.py @@ -1692,17 +1692,18 @@ def api_add_crawler_task(data, user_id=None): return {'error': 'The access to this cookiejar is restricted'}, 403 cookiejar_uuid = cookiejar.uuid - cookie = data.get('cookie', None) - if not cookiejar_uuid and cookie: + cookies = data.get('cookies', None) + if not cookiejar_uuid and cookies: # Create new cookiejar cookiejar_uuid = create_cookiejar(user_id, "single-shot cookiejar", 1, None) cookiejar = Cookiejar(cookiejar_uuid) - try: - name = cookie.get('name') - value = cookie.get('value') - cookiejar.add_cookie(name, value, None, None, None, None, None) - except KeyError: - return {'error': 'Invalid cookie key, please submit a valid JSON', 'cookiejar_uuid': cookiejar_uuid}, 400 + for cookie in cookies: + try: + name = cookie.get('name') + value = cookie.get('value') + cookiejar.add_cookie(name, value, None, None, None, None, None) + except KeyError: + return {'error': 'Invalid cookie key, please submit a valid JSON', 'cookiejar_uuid': cookiejar_uuid}, 400 frequency = data.get('frequency', None) if frequency: