Answer the question
In order to leave comments, you need to log in
What POST parameters to send to receive a response?
Hello everyone, for an hour I've been racking my brains on what to do so that the site would give out a list of cars.
Here is the site itself: https://www.auto.de/
As for the R/URL: https://www.auto.de/service/user-actions/api/v1/st...
Here is the answer:
Help compose the request !!!
Here is mine, I still played with data but 0 profit:
headers = {
'accept': 'application/json',
'content-type': 'application/json;charset=UTF-8',
'referer': 'https://www.auto.de/search?MMS_GROUPS[0][MANUFACTURER]=Audi',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36',
}
r = requests.post('https://www.auto.de/service/user-actions/api/v1/stats/viewers', headers=headers)
r = r.json()
Answer the question
In order to leave comments, you need to log in
Maybe for potmou that in order to get a response from the server, you need to use a GET request and not POST?
Well, copy the data from the browser and paste it into the code. ctrl+c ctrl+v task
data = {"carIds":["06a638ab-94b0-4bc7-93c4-d7587b024c77","4cbc03a9-3a4a-478b-8dea-71fe75e2b4ec","7d6a26c9-1e57-4f80-8a06-084bbefaa696","c6f9abd0-d20f-4082-a2bc-1b20f945d0b6","084c175e-e04a-4b47-aaeb-51675284ed84","fa3b0d28-a06d-4bac-bee7-7a56ab5fa829","8c8eba93-f1fa-4f01-ab37-c9a7a2a9f52a","d17b1964-e2a8-4544-afc4-df88ae683ce8","32b960f3-7297-4f90-a06b-6ad8bfe47115","df7b4fc7-f5aa-4a21-9b1b-9700981be14b","3ee17ea7-1654-49b4-9935-4851321fb199","3a3862fe-eb2b-4eec-b640-b9581698ce3b","9be428b5-d035-4384-8936-afa0463e69b3","e0f66af8-eaea-4ba0-a0fe-108fd0cb2aeb","6b9f0304-d4f6-423e-97d0-7799f55a4e0c","90e87e68-37ea-401d-96be-ba9d9783bcd7","d902b121-cb46-4e1e-9b28-53f706ae4b8d","34f18e6c-bf90-42c6-9703-69edc8d4b92b","94baba92-a805-4d8f-a330-2571907afc5e","95f51df1-0746-4bf7-947f-9c9baafae68e"]}
r = requests.post('https://www.auto.de/service/user-actions/api/v1/stats/viewers', headers=headers, json=data)
r = r.json()
print(r)
If you want to receive json, you need to pass "'content-type': 'application/json'" in the header.
In POST, you need to pass "carIds" as a parameter:
import requests
headers = {'content-type': 'application/json'}
data = '{"carIds":["06a638ab-94b0-4bc7-93c4-d7587b024c77","4cbc03a9-3a4a-478b-8dea-71fe75e2b4ec","7d6a26c9-1e57-4f80-8a06-084bbefaa696","c6f9abd0-d20f-4082-a2bc-1b20f945d0b6","084c175e-e04a-4b47-aaeb-51675284ed84","fa3b0d28-a06d-4bac-bee7-7a56ab5fa829","8c8eba93-f1fa-4f01-ab37-c9a7a2a9f52a","d17b1964-e2a8-4544-afc4-df88ae683ce8","32b960f3-7297-4f90-a06b-6ad8bfe47115","df7b4fc7-f5aa-4a21-9b1b-9700981be14b","3ee17ea7-1654-49b4-9935-4851321fb199","3a3862fe-eb2b-4eec-b640-b9581698ce3b","9be428b5-d035-4384-8936-afa0463e69b3","e0f66af8-eaea-4ba0-a0fe-108fd0cb2aeb","6b9f0304-d4f6-423e-97d0-7799f55a4e0c","90e87e68-37ea-401d-96be-ba9d9783bcd7","d902b121-cb46-4e1e-9b28-53f706ae4b8d","34f18e6c-bf90-42c6-9703-69edc8d4b92b","94baba92-a805-4d8f-a330-2571907afc5e","95f51df1-0746-4bf7-947f-9c9baafae68e"]}'
response = requests.post('https://www.auto.de/service/user-actions/api/v1/stats/viewers', headers=headers, data=data)
print(response.text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question