I need help to get all the cookies I would get from a page using a webdriver, but using requests. I’m trying to get info from a page. In this case there are some cookies that I think are being loaded by Javascript, also some of them are Akamai cookies. I don’t need to get the valid akamai cookies, just all the cookies a regular user would get.
Need this to be made by request in Python. This is my code
import tls_client
from http.cookiejar import CookieJar
import time
url = "https://www.fansale.at/tickets/all/taylor-swift/502069/17337901"
normal_header = {
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'accept-language': 'en-US,en;q=0.9,es;q=0.8',
'cache-control': 'max-age=0',
'priority': 'u=0, i',
'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'document',
'sec-fetch-mode': 'navigate',
'sec-fetch-site': 'same-origin',
'sec-fetch-user': '?1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
}
s = tls_client.Session(
ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
h2_settings={
"HEADER_TABLE_SIZE": 65536,
"MAX_CONCURRENT_STREAMS": 1000,
"INITIAL_WINDOW_SIZE": 6291456,
"MAX_HEADER_LIST_SIZE": 262144
},
h2_settings_order=[
"HEADER_TABLE_SIZE",
"MAX_CONCURRENT_STREAMS",
"INITIAL_WINDOW_SIZE",
"MAX_HEADER_LIST_SIZE"
],
supported_signature_algorithms=[
"ECDSAWithP256AndSHA256",
"PSSWithSHA256",
"PKCS1WithSHA256",
"ECDSAWithP384AndSHA384",
"PSSWithSHA384",
"PKCS1WithSHA384",
"PSSWithSHA512",
"PKCS1WithSHA512",
],
supported_versions=["GREASE", "1.3", "1.2"],
key_share_curves=["GREASE", "X25519"],
cert_compression_algo="brotli",
pseudo_header_order=[
":method",
":authority",
":scheme",
":path"
],
connection_flow=15663105,
header_order=[
"accept",
"user-agent",
"accept-encoding",
"accept-language"
]
)
def first():
if cookiess != None:
s.get(url=url, headers=normal_header, cookies=cookiess)
else:
s.get(url=url, headers=normal_header)
cookies = s.cookies
abck = cookies['_abck']
bm_sz = cookies['bm_sz']
for cookie in cookies:
print(cookie)
return abck, bm_sz, cookies
abck, bm_sz, cookies = first()
These are the cookies I get
<Cookie JSESSIONID=D9D8DFDCCB61FD164417EA5520119FA5 for www.fansale.at/>
<Cookie AF=FAU for www.fansale.at/>
<Cookie fansale.LOCALE=de for www.fansale.at/>
<Cookie access.FANSALE=1720613405427 for www.fansale.at/>
<Cookie BIGipServer~WEB~tickets.fansale.de=rd1o00000000000000000000ffff0ac01076o80 for www.fansale.at/>
<Cookie bm_ss=ab8e18ef4e for .fansale.at/>
<Cookie _abck=6C695C63673CA1C6F04D815ECFA8D6D6~-1~YAAQkLU+F+dSkZeQAQAAyASNnAy9u0gXFuOozKEyr8JHjMR/JFf4n35k9Z3RrcujPXrI4aRzBwAn83a8OWynAr7H4Dh6l6SSt3OmkWd8Mkn8WrQ50nBiYfSi3G0l4NSVgVN7a4AikBqZWd4Edx3pzw4XBEdqwiifOBBEvKKxXSN+F/LmB7ppFxD5cfbQIH5CU1mjR84PiPncnrobCyicZN7f8A1TxtKRlLo2L2+mu0PsYi9ycb8LNX68WW/I7+aububqRbry108rgBvK4+LyccUBC8D711CvlfMaopdt1sJgXrxtXI+1gwE/POby9JNFrOVuE46MuEGKAuywfeTKCNCXrxMIbhnlrC81vmaMs1B2Ntus52YxBMfIEXk=~-1~-1~-1 for .fansale.at/>
<Cookie bm_s=YAAQkLU+F+lSkZeQAQAAyASNnAFyqFdz+klvS87THs6V47N+V7XWYMqlWy7UFi2E1cbY4yRsOqah42kIV+Ozg6oKsscV1PCSzKxoxM4SbRIOKpx6xoUJFYvPLo0B4gMAQijPyDo/2TyLOV9/PItd1WyKx5lWFTeJYV4O+QwU0QtFcdBKMuNBYk4ftjjKwoqlO2+JphWkVcNll4tqCKIDUQyiTHnEeQJFzatXteF7i0ZjAKnXUU0nUz6b5olcv+Zr94DBo9CB///4VyXWEShxAaS1m6GY75JZWCaD6ekMjrP9Kzf/pfLsRBUHT2OHVr3/Gthprpc/n2RTgZcEi6+XUCUf7jeqrA== for .fansale.at/>
<Cookie bm_sz=7A57F29FE33909B1B1E81E72A6E222DC~YAAQkLU+F+pSkZeQAQAAyASNnBiBclzLAxuztgw8YQ+XGveCtUMIf15E32hSY8oiWro7u0hB1n4AcK9YgHFt8Q6PJel3ZP9W04Tlo+LpGzIqrNbPLxZtRj3rUCtk4xm994WkHopSFHiSQHy9krDhv4aTRboEYU4SucMo0q2akEgVKJ4NFJXUiTCurnlMfOIDalLOpTINMga6Ivy1FFrzylfjZvVy12VnhgkKO5IWVW4rG8KeZ7SmsTy+hs0tm4jIMCrLT5ZqzVrIhtJgmEWqlO5iIeB/r4258XmzLgF0YXn1cShcB3CJeeX+63h5AT4npTfdUAQ9SH01Gir9/Ow8C2UXt1Bh9kixEZnOYaepmhjVy8+LApOD5U6bhkLGhS53IcAL6u9RGQ==~3420997~3360321 for .fansale.at/>
I did a request with tls_client defined with its orders, but I don’t actually know if they are good, and tried to get all cookies apart from Akamai ones, but it just returns some of them.
Pablo Ortiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.