示例#1
0
 /**
  * retrieve the search result data from the given url
  *
  * @param $url
  * @param bool $detailedAd
  *
  * @return array
  */
 public function search($url, $detailedAd = false)
 {
     $searchData = new SearchResultCrawler((string) $this->httpClient->get($url)->getBody());
     $url = new SearchResultUrlParser($url, $searchData->getNbPages());
     $ads = $detailedAd ? $searchData->getAds() : $searchData->getAdsId();
     $sumarize = ['total_ads' => $searchData->getNbAds(), 'total_page' => $searchData->getNbPages(), 'ads_per_page' => $searchData->getNbAdsPerPage(), 'category' => $url->getCategory(), 'location' => $url->getLocation(), 'search_area' => $url->getSearchArea(), 'sort_by' => $url->getSortType(), 'type' => $url->getType(), 'ads' => $ads];
     return array_merge($url->getNav(), $sumarize);
 }
 public function testCheckTheContentOfTheFirstAds()
 {
     $search = new SearchResultCrawler($this->searchContent);
     $this->assertEquals(35, count($search->getAds()));
 }