MCPcopy Create free account
hub / github.com/cxapython/catvm / headers_to_scrapy

Function headers_to_scrapy

selenium/scrapy_splash/utils.py:92–110  ·  view source on GitHub ↗

Return scrapy.http.Headers instance from headers data. 3 data formats are supported: * {name: value, ...} dict; * [(name, value), ...] list; * [{'name': name, 'value': value'}, ...] list (HAR headers format).

(headers)

Source from the content-addressed store, hash-verified

90
91
92def headers_to_scrapy(headers):
93 """
94 Return scrapy.http.Headers instance from headers data.
95 3 data formats are supported:
96
97 * {name: value, ...} dict;
98 * [(name, value), ...] list;
99 * [{'name': name, 'value': value'}, ...] list (HAR headers format).
100 """
101 if isinstance(headers or {}, dict):
102 return Headers(headers or {})
103
104 if isinstance(headers[0], dict):
105 return Headers([
106 (d['name'], d.get('value', ''))
107 for d in headers
108 ])
109
110 return Headers(headers)
111
112
113def scrapy_headers_to_unicode_dict(headers):

Callers 1

_load_from_jsonMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected