apify 1.5.5b1__py3-none-any.whl → 1.5.6b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of apify might be problematic. Click here for more details.

apify/scrapy/requests.py CHANGED
@@ -5,6 +5,7 @@ import pickle
5
5
 
6
6
  try:
7
7
  from scrapy import Request, Spider
8
+ from scrapy.http.headers import Headers
8
9
  from scrapy.utils.request import request_from_dict
9
10
  except ImportError as exc:
10
11
  raise ImportError(
@@ -37,10 +38,16 @@ def to_apify_request(scrapy_request: Request, spider: Spider) -> dict:
37
38
  apify_request = {
38
39
  'url': scrapy_request.url,
39
40
  'method': scrapy_request.method,
40
- 'headers': scrapy_request.headers,
41
41
  'userData': scrapy_request.meta.get('userData', {}),
42
42
  }
43
43
 
44
+ if isinstance(scrapy_request.headers, Headers):
45
+ apify_request['headers'] = dict(scrapy_request.headers.to_unicode_dict())
46
+ else:
47
+ Actor.log.warning(
48
+ f'scrapy_request.headers is not an instance of the scrapy.http.headers.Headers class, scrapy_request.headers = {scrapy_request.headers}',
49
+ )
50
+
44
51
  # Add 'id' to the apify_request
45
52
  if scrapy_request.meta.get('apify_request_id'):
46
53
  apify_request['id'] = scrapy_request.meta['apify_request_id']
@@ -129,7 +136,12 @@ def to_scrapy_request(apify_request: dict, spider: Spider) -> Request:
129
136
 
130
137
  # Add optional 'headers' field
131
138
  if 'headers' in apify_request:
132
- scrapy_request.headers = apify_request['headers']
139
+ if isinstance(apify_request['headers'], dict):
140
+ scrapy_request.headers = Headers(apify_request['headers'])
141
+ else:
142
+ Actor.log.warning(
143
+ f'apify_request[headers] is not an instance of the dict class, apify_request[headers] = {apify_request["headers"]}',
144
+ )
133
145
 
134
146
  # Add optional 'userData' field
135
147
  if 'userData' in apify_request:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: apify
3
- Version: 1.5.5b1
3
+ Version: 1.5.6b1
4
4
  Summary: Apify SDK for Python
5
5
  Author-email: "Apify Technologies s.r.o." <support@apify.com>
6
6
  License: Apache Software License
@@ -21,7 +21,7 @@ apify/_memory_storage/resource_clients/key_value_store_collection.py,sha256=CBTc
21
21
  apify/_memory_storage/resource_clients/request_queue.py,sha256=6skV2fGpDxrDtn43oQIiBxd4kA5wJ8ygw7_Yy1q7M_M,19700
22
22
  apify/_memory_storage/resource_clients/request_queue_collection.py,sha256=qW7kPLKRl5mukIGCT8iNCsXT82BUYSwCV_KH7MLj528,1713
23
23
  apify/scrapy/__init__.py,sha256=xrhyVgPvdB_kB6ugkhUM4YM3WkvBUu5ZiV_4bW11LwM,195
24
- apify/scrapy/requests.py,sha256=pte0ODpI7pdRuKLfzfAeOlDoKnT0lReLVJZEn-YXqMY,5918
24
+ apify/scrapy/requests.py,sha256=A8lsAY6Zt31g6IvxWo8Yx-M4dHIRFaBX5q_PHQy_kpU,6511
25
25
  apify/scrapy/scheduler.py,sha256=kv4w52xydYTTzLCzbCYM77iAbE5fYKlw3SPeSudtTbE,4983
26
26
  apify/scrapy/utils.py,sha256=0vsa46ZlhxIg5a_f3UM10x3N3RezOKPEQy_hTHFa5Ws,4084
27
27
  apify/scrapy/middlewares/__init__.py,sha256=zzosV8BD8SZQIrVKsSaGFGV9rHinNLKm5GPL3ZNxSZQ,96
@@ -35,8 +35,8 @@ apify/storages/dataset.py,sha256=gfMlJ6dSXDdjCykkStZCyp4u8xKCIZqflGS9-jLzK74,233
35
35
  apify/storages/key_value_store.py,sha256=BUGYPI4MuRlOJ_aPzZr8bq7ay_K04qAZ7yKW7C8ItV4,10760
36
36
  apify/storages/request_queue.py,sha256=PP7KVZAQTR8-BPT54f-nk8Rbgkc5-bkDGFf4u_XQJLs,26957
37
37
  apify/storages/storage_client_manager.py,sha256=fvXg3PRojATNamEN29BBZyZZ5GWN_s0r29A59aiL-wQ,2465
38
- apify-1.5.5b1.dist-info/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
39
- apify-1.5.5b1.dist-info/METADATA,sha256=1fPCV_55bT1omk1JsteOotSBJimlh_HwJxPi_5F7Hdc,6236
40
- apify-1.5.5b1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
41
- apify-1.5.5b1.dist-info/top_level.txt,sha256=2oFNsHggn5m_rCaaP7xijQg_-Va2ByOSYuvKgACsS5w,6
42
- apify-1.5.5b1.dist-info/RECORD,,
38
+ apify-1.5.6b1.dist-info/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
39
+ apify-1.5.6b1.dist-info/METADATA,sha256=vORD2BUbG1kyMjL09jtLWH1ab-TUkxzaLH_d1SGUl-w,6236
40
+ apify-1.5.6b1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
41
+ apify-1.5.6b1.dist-info/top_level.txt,sha256=2oFNsHggn5m_rCaaP7xijQg_-Va2ByOSYuvKgACsS5w,6
42
+ apify-1.5.6b1.dist-info/RECORD,,