M
M
MihaSerg2020-08-21 18:30:55
Python
MihaSerg, 2020-08-21 18:30:55

How to pass Cookies through Headers?

I use the module of one Internet service.
It has this class

class ScraperAPIClient:
    def __init__(self, api_key):
        self.api_key = api_key

    def get(self,
            url,
            headers={},
            country_code=None,
            premium=None,
            render=None,
            session_number=None,
            autoparse=None,
            retry=3,
            timeout=60):
        return makeRequestWithMethod(url, self.api_key, "GET", headers, country_code, premium, render, session_number,
                                     autoparse, retry, timeout, None)
...


Accordingly, an object is created and its method is called:
client = ScraperAPIClient('34hg32423g5h42j345234gj6776k')
result = client.get(url = 'http://httpbin.org/ip', headers = {"X-MyHeader": "123"})


Question. How to pass cookie in such request. It is necessary to transfer such
'aep_usuc_f' : 'isfm=y&site=rus&c_tp=RUB&isb=y&region=RU&b_locale=ru_RU'

How to enter it here? I contacted the service support. The answer was: You send cookies in the "Cookie" header. So I did not understand anything. Enter as a pair 'aep_usuc_f' : 'isfm=y&site=rus&c_tp=RUB&isb=y®ion=RU&b_locale=ru_RU' in headers or something else?

This is all from the module of one internet service ( https://www.scraperapi.com/ ). I wrote to their support about this issue. Answered: You send cookies in the "Cookie" header. Understood nothing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Ternick, 2020-08-21
@MihaSerg

Well, in principle, this can be done something like this:

client = ScraperAPIClient('34hg32423g5h42j345234gj6776k')
result = client.get(url = 'http://httpbin.org/ip', headers = {"X-MyHeader": "123", "Cookie": "aep_usuc_f=isfm=y&site=rus&c_tp=RUB&isb=y&region=RU&b_locale=ru_RU"})

Might help)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question