Thanks @Mantisus . This was my soluction and it works for me:
cookie_header = "; ".join([f"{cookie['name']}={cookie['value']}" for cookie in cookies])
# type of cookies is a list of dicts
headers = {
'content-type': 'application/x-www-form-urlencoded',
'accept-language': 'en-US,en;q=0.9',
'cookie': cookie_header,
}
initial_req = Request.from_url(
url=url,
method="POST",
label="LISTINGS",
headers=headers,
payload=urlencode(get_payload(0)).encode(),
use_extended_unique_key=True,
user_data={
"page_index": 0,
"headers": headers
},
)
await crawler.run([initial_req])
I use the headers in the next request (in the handler) that I have passed in user_data