public function getAds($url, $maxAds = 0)
    {
        $ads        = [];
        $pageNumber = 1;
        $fetchedAds = 0;

        do {
            $crawler = $this->client->request('GET', $url, [
                'o' => $pageNumber,
            ]);

            $totalAds = str_replace(' ', '',
                $crawler->filter('#listingAds section header nav a')->first()->filter('span')->text()
            );

            $nbAdsInPage = $crawler->filter('#listingAds > section > section > ul > li')->count();

            $ads += $this->_fetchAds($crawler, $fetchedAds, $maxAds);

            $fetchedAds += $nbAdsInPage;
            $pageNumber++;
        } while ($fetchedAds < $totalAds && ($maxAds == 0 || $fetchedAds < $maxAds));

        return array_slice($ads, 0, $maxAds ? $maxAds : count($ads));
    }
public function getAds($url, $maxAds = 0)
    {
        $ads        = [];
        $pageNumber = 1;
        $fetchedAds = 0;

        do {
            $crawler = $this->client->request('GET', $url, [
                'o' => $pageNumber,
            ]);

            $totalAds = str_replace(' ', '',
                $crawler->filter('#listingAds section header nav a')->first()->filter('span')->text()
            );

            $nbAdsInPage = $crawler->filter('#listingAds > section > section > ul > li')->count();

            $ads += $this->_fetchAds($crawler, $fetchedAds, $maxAds);

            $fetchedAds += $nbAdsInPage;
            $pageNumber++;
        } while ($fetchedAds < $totalAds && ($maxAds == 0 || $fetchedAds < $maxAds));

        return array_slice($ads, 0, $maxAds ? $maxAds : count($ads));
    }
public function getAds ( $ url , $ maxAds = 0 ) { $ ads = [ ] ; $ pageNumber = 1 ; $ fetchedAds = 0 ; do { $ crawler = $ this -> client -> request ( 'GET' , $ url , [ 'o' => $ pageNumber , ] ) ; $ totalAds = str_replace ( ' ' , '' , $ crawler -> filter ( '#listingAds section header nav a' ) -> first ( ) -> filter ( 'span' ) -> text ( ) ) ; $ nbAdsInPage = $ crawler -> filter ( '#listingAds > section > section > ul > li' ) -> count ( ) ; $ ads += $ this -> _fetchAds ( $ crawler , $ fetchedAds , $ maxAds ) ; $ fetchedAds += $ nbAdsInPage ; $ pageNumber ++ ; } while ( $ fetchedAds < $ totalAds && ( $ maxAds == 0 || $ fetchedAds < $ maxAds ) ) ; return array_slice ( $ ads , 0 , $ maxAds ? $ maxAds : count ( $ ads ) ) ; }
Get the list of all available ads

Returns an array of ads where one ad has the following format:

array(7) {
["url"]=>
string(52) "https://www.leboncoin.fr/velos/934826585.htm?ca=12_s"
["image"]=>
string(81) "https://img1.leboncoin.fr/thumbs/010/010a091e6f370cf14f1bf446be768a92e6342d7f.jpg"
["title"]=>
string(50) "Collier BBB 31.8mm ALU dérailleur avant à BRASER"
["category"]=>
string(6) "Vélos"
["location"]=>
string(33) "Carrières-sous-Poissy / Yvelines"
["price"]=>
string(7) "10 €"
["date"]=>
string(18) "Aujourd'hui, 14:12"
}

@param srring $url    the url that leads to search results
@param int    $maxAds max number of ads to fetch (0 = gets all ads)

@return array    $ads
Get the list of all available ads