How to fix the endless work of my parser on PHP and CURL?

by Dio   Last Updated October 10, 2019 20:26 PM

I need to make a parser that will read the specified number of links for example 80. I can’t figure out how to save or read all the links displayed on the screen. Now the parser is working endlessly.

<?php
$page = 1;
$total = fPars('https://www.dns-shop.ru/catalog/17a892f816404e77/noutbuki/?p=1&order=1&groupBy=none&stock=2', $page);

function fPars($parsLink, $page){
    $arr = parse_url($parsLink);
    parse_str($arr['query'],$query);
    $query['p'] = $page;
    $query = http_build_query($query);
    $url = $arr['scheme'].'://'.$arr['host'].$arr['path'].'?'.$query;

    $html = curl_get($url);
    $dom = str_get_html($html);
    $links = $dom->find('.product-info__title-link');
    $page = $page +1;
    foreach ($links as $link) {
        echo $link . '<br/>';
    }
    if (count($links) < 80) {
        fPars($url, $page);
    }
}
?>
Tags : php parsing curl


Related Questions


Updated September 15, 2017 08:26 AM

Updated April 29, 2018 18:26 PM

Updated December 31, 2018 11:26 AM

Updated August 30, 2017 00:26 AM

Updated August 02, 2016 08:11 AM