| 1 | <?php |
||
| 5 | class SearchResultCrawler extends CrawlerAbstract |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Return the total number of ads of the search |
||
| 9 | * |
||
| 10 | * @return int |
||
| 11 | */ |
||
| 12 | 6 | public function getNbAds() |
|
| 13 | { |
||
| 14 | 6 | $nbAds = $this->crawler |
|
| 15 | 6 | ->filter('a.tabsSwitch span.tabsSwitchNumbers') |
|
| 16 | 6 | ->first(); |
|
| 17 | |||
| 18 | 6 | if ($nbAds->count()) { |
|
| 19 | 6 | $nbAds = preg_replace('/\s+/', '', $nbAds->text()); |
|
| 20 | 6 | return (int) $nbAds; |
|
| 21 | } |
||
| 22 | |||
| 23 | return 0; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Return the number of ads per page. |
||
| 28 | * |
||
| 29 | * Could be dynamically guessed in future, if Leboncoin change it frequently |
||
| 30 | * Or if they add the ability for user to change it on result pages. |
||
| 31 | * |
||
| 32 | * |
||
| 33 | * @return int |
||
| 34 | */ |
||
| 35 | 6 | public function getNbAdsPerPage() |
|
| 39 | |||
| 40 | /** |
||
| 41 | * Return the number of page |
||
| 42 | * |
||
| 43 | * @return int |
||
| 44 | */ |
||
| 45 | 6 | public function getNbPages() |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Get an array containing the ads of the current result page |
||
| 52 | * |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | 4 | public function getAds() |
|
| 67 | |||
| 68 | /** |
||
| 69 | * Return the Ad's ID |
||
| 70 | * |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | 4 | public function getAdsId() |
|
| 84 | } |
||
| 85 |