示例#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 testTheAdsId()
 {
     $search = new SearchResultCrawler($this->searchContent);
     $expected = ['753862363', '753850295', '753843597', '753832063', '753825535', '753824979', '729205464', '742650820', '750621938', '690318904', '753766957', '753764441', '742651186', '753759783', '748237410', '729132192', '753726642', '753723041', '702115601', '733979787', '728015610', '746360177', '744534260', '691276807', '753354997', '691269084', '712484305', '662053785', '710735683', '750941004', '746609897', '746990846', '753621234', '753606675', '746080950'];
     $this->assertEquals($expected, $search->getAdsId());
 }