categories added
This commit is contained in:
parent
832c503278
commit
642e4173d1
1 changed files with 151 additions and 47 deletions
|
@ -6,15 +6,17 @@ class LeBonCoinBridge extends BridgeAbstract{
|
||||||
$this->maintainer = "16mhz";
|
$this->maintainer = "16mhz";
|
||||||
$this->name = "LeBonCoin";
|
$this->name = "LeBonCoin";
|
||||||
$this->uri = "http://www.leboncoin.fr";
|
$this->uri = "http://www.leboncoin.fr";
|
||||||
$this->description = "Returns most recent results from LeBonCoin for a region and a keyword.";
|
$this->description = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword .";
|
||||||
$this->update = "2015-10-30";
|
$this->update = "2016-05-02";
|
||||||
|
|
||||||
$this->parameters[] =
|
$this->parameters[] =
|
||||||
'[
|
'[
|
||||||
|
|
||||||
{
|
{
|
||||||
"name" : "Keyword",
|
"name" : "Mot Clé",
|
||||||
"identifier" : "k"
|
"identifier" : "k"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"name" : "Région",
|
"name" : "Région",
|
||||||
"identifier" : "r",
|
"identifier" : "r",
|
||||||
|
@ -125,62 +127,164 @@ class LeBonCoinBridge extends BridgeAbstract{
|
||||||
"value" : "reunion"
|
"value" : "reunion"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "Catégorie",
|
||||||
|
"identifier" : "c",
|
||||||
|
"type" : "list",
|
||||||
|
"values" : [
|
||||||
|
{ "name" : "---- Select ----", "value" : "" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "EMPLOI", "value" : "_emploi_" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "VEHICULES", "value" : "_vehicules_" },
|
||||||
|
{ "name" : " Voitures", "value" : "voitures" },
|
||||||
|
{ "name" : " Motos", "value" : "motos" },
|
||||||
|
{ "name" : " Caravaning", "value" : "caravaning" },
|
||||||
|
{ "name" : " Utilitaires", "value" : "utilitaires" },
|
||||||
|
{ "name" : " Equipement Auto", "value" : "equipement_auto" },
|
||||||
|
{ "name" : " Equipement Moto", "value" : "equipement_moto" },
|
||||||
|
{ "name" : " Equipement Caravaning", "value" : "equipement_caravaning" },
|
||||||
|
{ "name" : " Nautisme", "value" : "nautisme" },
|
||||||
|
{ "name" : " Equipement Nautisme", "value" : "equipement_nautisme" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "IMMOBILIER", "value" : "_immobilier_" },
|
||||||
|
{ "name" : " Ventes immobilieres", "value" : "ventes_immobilieres" },
|
||||||
|
{ "name" : " Locations", "value" : "locations" },
|
||||||
|
{ "name" : " Colocations", "value" : "colocations" },
|
||||||
|
{ "name" : " Bureaux & Commerces", "value" : "bureaux_commerces" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "VACANCES", "value" : "_vacances_" },
|
||||||
|
{ "name" : " Locations gites", "value" : "locations_gites" },
|
||||||
|
{ "name" : " Chambres d\'hôtes", "value" : "chambres_d_hotes" },
|
||||||
|
{ "name" : " Campings", "value" : "campings" },
|
||||||
|
{ "name" : " Hôtels", "value" : "hotels" },
|
||||||
|
{ "name" : " Hébergements insolites", "value" : "hebergements_insolites" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "MULTIMEDIA", "value" : "_multimedia_" },
|
||||||
|
{ "name" : " Informatique", "value" : "informatique" },
|
||||||
|
{ "name" : " Consoles & Jeux vidéo", "value" : "consoles_jeux_video" },
|
||||||
|
{ "name" : " Image & Son", "value" : "image_son" },
|
||||||
|
{ "name" : " Téléphonie", "value" : "telephonie" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "LOISIRS", "value" : "_loisirs_" },
|
||||||
|
{ "name" : " DVD / Films", "value" : "dvd_films" },
|
||||||
|
{ "name" : " CD / Musique", "value" : "cd_musique" },
|
||||||
|
{ "name" : " Livres", "value" : "livres" },
|
||||||
|
{ "name" : " Animaux", "value" : "animaux" },
|
||||||
|
{ "name" : " Vélos", "value" : "velos" },
|
||||||
|
{ "name" : " Sports & Hobbies", "value" : "sports_hobbies" },
|
||||||
|
{ "name" : " Instruments de musique", "value" : "instruments_de_musique" },
|
||||||
|
{ "name" : " Collection", "value" : "collection" },
|
||||||
|
{ "name" : " Jeux & Jouets", "value" : "jeux_jouets" },
|
||||||
|
{ "name" : " Vins & Gastronomie", "value" : "vins_gastronomie" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "MATERIEL PROFESSIONNEL", "value" : "_materiel_professionnel_" },
|
||||||
|
{ "name" : " Materiel Agricole", "value" : "materiel_agricole" },
|
||||||
|
{ "name" : " Transport - Manutention", "value" : "transport_manutention" },
|
||||||
|
{ "name" : " BTP - Chantier - Gros-oeuvre", "value" : "btp_chantier_gros_oeuvre" },
|
||||||
|
{ "name" : " Outillage - Materiaux 2nd-oeuvre", "value" : "outillage_materiaux_2nd_oeuvre" },
|
||||||
|
{ "name" : " Equipements Industriels", "value" : "equipements_industriels" },
|
||||||
|
{ "name" : " Restauration - Hôtellerie", "value" : "restauration_hotellerie" },
|
||||||
|
{ "name" : " Fournitures de Bureau", "value" : "fournitures_de_bureau" },
|
||||||
|
{ "name" : " Commerces & Marchés", "value" : "commerces_marches" },
|
||||||
|
{ "name" : " Matériel médical", "value" : "materiel_medical" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "SERVICES", "value" : "_services_" },
|
||||||
|
{ "name" : " Prestations de services", "value" : "prestations_de_services" },
|
||||||
|
{ "name" : " Billetterie", "value" : "billetterie" },
|
||||||
|
{ "name" : " Evénements", "value" : "evenements" },
|
||||||
|
{ "name" : " Cours particuliers", "value" : "cours_particuliers" },
|
||||||
|
{ "name" : " Covoiturage", "value" : "covoiturage" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "MAISON", "value" : "_maison_" },
|
||||||
|
{ "name" : " Ameublement", "value" : "ameublement" },
|
||||||
|
{ "name" : " Electroménager", "value" : "electromenager" },
|
||||||
|
{ "name" : " Arts de la table", "value" : "arts_de_la_table" },
|
||||||
|
{ "name" : " Décoration", "value" : "decoration" },
|
||||||
|
{ "name" : " Linge de maison", "value" : "linge_de_maison" },
|
||||||
|
{ "name" : " Bricolage", "value" : "bricolage" },
|
||||||
|
{ "name" : " Jardinage", "value" : "jardinage" },
|
||||||
|
{ "name" : " Vêtements", "value" : "vetements" },
|
||||||
|
{ "name" : " Chaussures", "value" : "chaussures" },
|
||||||
|
{ "name" : " Accessoires & Bagagerie", "value" : "accessoires_bagagerie" },
|
||||||
|
{ "name" : " Montres & Bijoux", "value" : "montres_bijoux" },
|
||||||
|
{ "name" : " Equipement bébé", "value" : "equipement_bebe" },
|
||||||
|
{ "name" : " Vêtements bébé", "value" : "vetements_bebe" },
|
||||||
|
|
||||||
|
{ "name" : "", "value" : "" },
|
||||||
|
{ "name" : "AUTRES", "value" : "autres" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]';
|
]';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
$link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']);
|
if (empty($param['c'])) {
|
||||||
$html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404);
|
$link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$link = 'http://www.leboncoin.fr/' . $param['c'] . '/offres/' . $param['r'] . '/?f=a&th=1&q=' . urlencode($param['k']);
|
||||||
|
}
|
||||||
|
$html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404);
|
||||||
|
|
||||||
$list = $html->find('.tabsContent', 0);
|
$list = $html->find('.tabsContent', 0);
|
||||||
if($list === NULL) {
|
if($list === NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = $list->find('li');
|
|
||||||
|
|
||||||
foreach($tags as $element) {
|
$tags = $list->find('li');
|
||||||
|
|
||||||
$element = $element->find('a', 0);
|
foreach($tags as $element) {
|
||||||
|
|
||||||
$item = new \Item();
|
|
||||||
$item->uri = $element->href;
|
|
||||||
$title = $element->getAttribute('title');
|
|
||||||
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
|
|
||||||
|
|
||||||
if($content_image !== NULL) {
|
|
||||||
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
|
|
||||||
} else {
|
|
||||||
$content = "";
|
|
||||||
}
|
|
||||||
$date = $element->find('aside.item_absolute', 0)->find('p.item_sup', 0);
|
|
||||||
|
|
||||||
$detailsList = $element->find('section.item_infos', 0);
|
|
||||||
|
|
||||||
for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext;
|
$element = $element->find('a', 0);
|
||||||
$price = $detailsList->find('h3.item_price', 0);
|
|
||||||
$content .= $price === NULL ? '' : $price->plaintext;
|
|
||||||
|
|
||||||
$item->title = $title;
|
$item = new \Item();
|
||||||
$item->content = $content . $date;
|
$item->uri = $element->href;
|
||||||
$this->items[] = $item;
|
$title = $element->getAttribute('title');
|
||||||
}
|
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(){
|
if($content_image !== NULL) {
|
||||||
return 'LeBonCoin';
|
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
|
||||||
}
|
} else {
|
||||||
|
$content = "";
|
||||||
|
}
|
||||||
|
$date = $element->find('aside.item_absolute', 0)->find('p.item_sup', 0);
|
||||||
|
|
||||||
public function getURI(){
|
$detailsList = $element->find('section.item_infos', 0);
|
||||||
return 'http://www.leboncoin.fr';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCacheDuration(){
|
for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext;
|
||||||
return 3600; // 1 hour
|
$price = $detailsList->find('h3.item_price', 0);
|
||||||
}
|
$content .= $price === NULL ? '' : $price->plaintext;
|
||||||
}
|
|
||||||
|
$item->title = $title;
|
||||||
|
$item->content = $content . $date;
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
return 'LeBonCoinDev';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI(){
|
||||||
|
return 'http://www.leboncoin.fr';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCacheDuration(){
|
||||||
|
return 3600; // 1 hour
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue