P
P
panto2017-08-02 17:12:55
PHP
panto, 2017-08-02 17:12:55

Why cUrl does not want to output data when parsing Ajax?

For the sake of interest, I decided to parse sites with ajax, everything went well until I came across one site. I found an ajax request through the Google console and drove it into the cUrl line.

Actually the request itself from the site
https://anapa.etagi.com/msearcher_ajax.php?action=...

Through the browser it displays some kind of array of data, and through curl - complete nonsense.
Script Code

$url  = 'https://anapa.etagi.com/msearcher_ajax.php?action=modular_search&subAction=objects&class=nh_flats&city_id=748&language=&count=0&isLoading=true&perPage=15&offset=0&currentPage=0&pageNum=0&type=&rooms=&district_id=&metro_station_id=&street_id=&trakt_id=&typesAnalytics=&wall_id=&series_id=&keep=&class=nh_flats&builder_id=&newcomplex_id=&object_id=&action_sl=&deadline_date=&collections=%5Bobject%20Object%5D&or=rooms&order=price%20asc&layoutType=0&realtyType=nh_flats';
    $ch = curl_init($url);

    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);

  
    $html = curl_exec($ch);
    curl_close($ch);
    print_r($html);

I could not find anything intelligible on this problem. Via print_r($html);outputs something like: ���]s#ו5����sN~�1�c:���c�\�HI*��R���*��v��[�~d �r�C���0%�$�JEE�$���Kf��`fQI&
Maybe someone faced such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-08-02
@panto

I bet on gzip
curl_setopt($ch, CURLOPT_ENCODING , "gzip");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question