I make an application on Android and I want to extract data from the drop-down menu using AJAX.
In the chrome console, the page to which the request is sent when you click contains the end of the address.xhtml?cid=5
I delete this parameter and send the request again - nothing works, the response is in error.
Each time this variable is of different size.
How to find out what value to choose?
- Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin ♦
2 answers
So there is a simple protection from bots. Or it is a meaningful variable that identifies a submenu for example. Such things are done by robots - which, for example, run once an hour, rip out this data and put it on your server.
Try to do so - first send a request to the page containing the drop-down menu, or a link with this parameter. Pull out the link - take a break for example. And then make a request to the URL that you captured.
But this method is bad because the pages may not always be available and may not always give you the correct answer + to the fact that you cannot control the time of the request - if someone else’s server slows down.
- I already did, does not help. The page on which this menu lies is valid with cid = 1, and when I click on the element I need, the cid is already different, and with each click it is different - Alex
- oneSo there are also cookies being sent. Try in the firewall to select the option "Copy as curl" in the drop-down menu of the request - in the server console then execute, you will receive what you need successfully. Then, by eliminating the curl-parameters, you find out what you lack for success — most likely a cookie. There may be additional headers. - Goncharov Alexander
- Thanks, I will try - Alex
- Either I am a fool or skis do not go) in the copied cURL exactly the same headers as in my request - Alex
As reported by @Sergey CID, this conversation ID. It does not have time to change when you click, so we remove this parameter from the page from which we click and voila. The XHR displays the desired result.