1
0

ParuVenduImmoBridge.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * RssBridge Paru Vendu Immo
  4. * Retrieve lastest documents from http://www.paruvendu.fr/immobilier/.
  5. *
  6. * @name Paru Vendu Immobilier
  7. * @homepage http://www.paruvendu.fr/immobilier/
  8. * @description Returns the ads from the first page of search result.
  9. * @maintainer polo2ro
  10. * @update 2015-02-02
  11. * @use1(minarea="Min surface m²",maxprice="Max price",pa="Country code (ex: FR)",lo="department numbers or postal codes, comma-separated")
  12. */
  13. class ParuVenduImmoBridge extends BridgeAbstract
  14. {
  15. private $request = '';
  16. public function collectData(array $param)
  17. {
  18. $html = '';
  19. $num = 20;
  20. $appartment = '&tbApp=1&tbDup=1&tbChb=1&tbLof=1&tbAtl=1&tbPla=1';
  21. $maison = '&tbMai=1&tbVil=1&tbCha=1&tbPro=1&tbHot=1&tbMou=1&tbFer=1';
  22. $link = $this->getURI().'/immobilier/annonceimmofo/liste/listeAnnonces?tt=1'.$appartment.$maison;
  23. if (isset($param['minarea'])) {
  24. $this->request .= ' '.$param['minarea'].' m2';
  25. $link .= '&sur0='.urlencode($param['minarea']);
  26. }
  27. if (isset($param['maxprice'])) {
  28. $link .= '&px1='.urlencode($param['maxprice']);
  29. }
  30. if (isset($param['pa'])) {
  31. $link .= '&pa='.urlencode($param['pa']);
  32. }
  33. if (isset($param['lo'])) {
  34. $this->request .= ' In: '.$param['lo'];
  35. $link .= '&lo='.urlencode($param['lo']);
  36. }
  37. $html = file_get_html($link) or $this->returnError('Could not request paruvendu.', 404);
  38. foreach($html->find('div.annonce a') as $element) {
  39. if (!$element->title) {
  40. continue;
  41. }
  42. $img ='';
  43. foreach($element->find('span.img img') as $img) {
  44. if ($img->original) {
  45. $img = '<img src="'.$img->original.'" />';
  46. }
  47. }
  48. $desc = $element->find('span.desc')[0]->innertext;
  49. $desc = str_replace("voir l'annonce", '', $desc);
  50. $price = $element->find('span.price')[0]->innertext;
  51. $item = new \Item();
  52. $item->uri = $this->getURI().$element->href;
  53. $item->title = $element->title;
  54. $item->content = $img.$desc.$price;
  55. $this->items[] = $item;
  56. }
  57. }
  58. public function getName(){
  59. return 'Paru Vendu Immobilier'.$this->request;
  60. }
  61. public function getURI(){
  62. return 'http://www.paruvendu.fr';
  63. }
  64. public function getCacheDuration(){
  65. return 10800; // 3 hours
  66. }
  67. }