A
A
aopil2020-11-24 20:16:58
PHP
aopil, 2020-11-24 20:16:58

Why am I not getting a result on a POST request?

Sending a POST request:

$ch = curl_init($url);
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => 'token='.$token.'&pdoduct=1&g-recaptcha-response=123',
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_COOKIEFILE     => $cookie,
    CURLOPT_COOKIEJAR      => $cookie,
    CURLOPT_ENCODING       => 'gzip, deflate'
));

I get a response 200, then I look htmlat the result, the whole page has loaded, but the expected result is missing, i.e. the whole page has loaded, but there is no div that would normally display the result of a query.

In the browser, looking at the inspector in the Network, I looked at the response to the request, and the necessary div is there.
Further, I noticed the following nuance:
Without closing the inspector, in the Network I update the page through F5and see a POST request, instead of the usual page update, and I view the response to this POST request, and surprisingly I do NOT see the same one there div, I will clarify that all parameters in the POST request are also passed.

Question: How so? It would seem that we are sending the same POST requests, but updating via F5 - there is no necessary div, as well as when sending via CURL.

Who can explain what this phenomenon is connected with?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya S, 2020-11-24
@Stalinko

The desired div is generated via JS on the fly. Open the source code in the browser - if this div is not there, then I'm right.
Accordingly, it is not so easy to scrape this page. It is necessary to light up where this div and the data in it come from.

G
galaxy, 2020-11-24
@galaxy

CURLOPT_POSTFIELDS => 'token='.$token.'&pdoduct=1&g-recaptcha-response=123',

The recaptcha token is rotten, most likely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question