You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking for a way to not store cookies in an AsyncSession.
I have the following code , but i noticed that cookies are stored between requests. When the site i'm trying to scrape detect i'm a bot it stores a cookie that is used again by all the requests of the session. I'd like to disable cookie storage.
Is there an easy way to do it ?
Thanks in advance
async with AsyncSession(
verify=False,
impersonate='chrome',
headers={'Connection': 'close'},
) as session:
async def make_single_request(request_id: str, request: Dict[str, Any]) -> Tuple[str, Optional[Response]]:
method = request.get('method', 'GET')
url = request['url']
for attempt in range(self.max_retries):
try:
kwargs = {
'params': request.get('params'),
'data': request.get('data'),
'headers': request.get('headers'),
'proxy': self.proxy_url,
'referer': request.get('referer')
}
if method == 'GET':
response = await session.get(url, **kwargs)
else:
response = await session.post(url, **kwargs)
if response.status_code in self.retry_status_codes:
raise Exception(f"Received status code {response.status_code}")
# Handle response encoding
#self._handle_response_encoding(response)
return request_id, response
The text was updated successfully, but these errors were encountered:
Hello everyone,
I'm looking for a way to not store cookies in an AsyncSession.
I have the following code , but i noticed that cookies are stored between requests. When the site i'm trying to scrape detect i'm a bot it stores a cookie that is used again by all the requests of the session. I'd like to disable cookie storage.
Is there an easy way to do it ?
Thanks in advance
The text was updated successfully, but these errors were encountered: