I have already asked a question about it but this time I would like to be more specific...
I am writing with python requests a program that automates the purchase on the European site https://www.zalando.it :
import requests
import pickle
import json
s = requests.Session()
headers1 = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'}
r = s.get('https://www.zalando.it/', headers = headers1)
cookies = r.cookies
headers = {
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
}
login = {
'email' : 'myemail@gmail',
'request': 'eyJjbGllbnRfaWQiOiJmYXNoaW9uLXN0b3JlLXdlYiIsInJlc3BvbnNlX3R5cGUiOiJjb2RlIiwic2NvcGVzIjpbIm9wZW5pZCJdLCJyZWRpcmVjdF91cmkiOiJodHRwczovL3d3dy56YWxhbmRvLml0L3Nzby9jYWxsYmFjayIsInN0YXRlIjoiZXlKdmNtbG5hVzVoYkY5eVpYRjFaWE4wWDNWeWFTSTZJbWgwZEhCek9pOHZkM2QzTG5waGJHRnVaRzh1YVhRdmRXOXRieTFvYjIxbEx5SXNJblJ6SWpvaU1qQXlNUzB4TVMwd00xUXhNVG93Tnpvd00xb2lmUT09Iiwibm9uY2UiOiJjZmU4NDZhOC0yYTQ1LTQ5MWUtYmI4OC0yNGYxYWViZDAzZDAiLCJ1aV9sb2NhbGVzIjpbIml0LUlUIl0sInJlcXVlc3RfaWQiOiJRd1BkZFhlcndEN1FmUmc4OmNkYTFhZDQ5LTZlMjMtNDE5Ny1iNjA0LTZiYjM5MDY1ZjY1MDozSTM4MlRNVDdIcGtpMnVrIn0=',
'secret':'mypassword'
}
cookies = {
'Zalando-Client-Id' : 'cda1ad49-6e23-4197-b604-6bb39065f650'
}
payload = {
"cartActionProductBrand": "Nike Sportswear",
"cartActionProductIsSale": 0,
"cartActionProductName": "AIR FORCE 1 '07 LV8 - Sneakers basse - white/black/game royal",
"cartActionProductPrice": "109.99",
"cartActionProductSize": "47",
"cartActionProductSku": "NI112O0M9-A120125000",
"event": "addToCart",
"flowId": "SZSnGMU4lwR60woT",
"host": "www.zalando.it",
"pathname": "/nike-sportswear-air-force-1-07-lv8-sneakers-basse-whiteblackgame-royal-ni112o0m9-a12.html",
"referrer": "https://www.zalando.it/scarpe-uomo/",
"accept_language": "it-IT"
}
r = s.post("https://www.zalando.it", headers=headers, cookies = cookies)
r = s.get("https://www.zalando.it/api/login/schema", headers=headers)
post = s.post("https://accounts.zalando.com/api/login", headers=headers, data=login, cookies = cookies)
print(post.text)
addToCart = s.post("https://www.zalando.it/api/rr/e", headers=headers, json=payload)
cart = s.get("https://www.zalando.it/cart/", headers=headers)
print(cart.text)
The program crashes on login and gives this result, maybe because there is a bot detector?: I get the payload from the chrome console (headers section).
{
"edge_error": "halt",
"ref_id": "18.ec871002.1636020991.e8b0e1f",
"wait": 60,
"feedback": {
"email": true,
"url": "",
"recaptcha": {
"enabled": false,
"type": 0,
"sitekey": ""
}
}
}
With selenium I had solved by importing my chrome profile, maybe I can do it here too?
Aucun commentaire:
Enregistrer un commentaire