Merge pull request #83 from 16mhz/master

LeBonCoin and Humble Store Discount bridges
This commit is contained in:
Mitsu 2014-07-22 18:09:50 +02:00
commit 9287e47163
2 changed files with 66 additions and 4 deletions

9
bridges/HumbleStoreDiscountBridge.php Normal file → Executable file
View file

@ -29,10 +29,12 @@ class HumbleStoreDiscountBridge extends BridgeAbstract{
$product_uri = $store_link . $value['machine_name']; $product_uri = $store_link . $value['machine_name'];
$platforms = str_replace('\'', '', implode("','", $value['platforms'])); $platforms = str_replace('\'', '', implode("','", $value['platforms']));
$delivery_methods = str_replace('\'', '', implode("','", $value['delivery_methods'])); $delivery_methods = str_replace('\'', '', implode("','", $value['delivery_methods']));
$thumbnail = 'https://www.humblebundle.com' . $value['storefront_featured_image_small'];
$content = '<b>' . $product_name . '</b><br/><b>Current price:</b> ' . $new_price . '<br/><b>Full price:</b> ' . $full_price $content = '<img src="' . $thumbnail . '" alt="' . $value['storefront_featured_image_small'] . '"><br/><br/><b>' . $product_name
. '<br/><b>Delivery methods:</b> ' . $delivery_methods . '<br/><b>Platforms:</b> ' . '</b><br/><br/><b>Current price:</b> ' . $new_price . '<br/><b>Full price:</b> ' . $full_price
. $platforms . '<br/>' . $value['description']; . '<br/><b>Developer:</b> ' . $value['developer_name'] . '<br/><b>Delivery methods:</b> ' . $delivery_methods
. '<br/><b>Platforms:</b> ' . $platforms . '<br/>' . $value['description'];
$item = new \Item(); $item = new \Item();
$item->title = $product_name . ' - ' . $new_price; $item->title = $product_name . ' - ' . $new_price;
@ -56,4 +58,3 @@ class HumbleStoreDiscountBridge extends BridgeAbstract{
return 21600; // 6 hours return 21600; // 6 hours
} }
} }

61
bridges/LeBonCoinBridge.php Executable file
View file

@ -0,0 +1,61 @@
<?php
/**
* RssBridgeLeBonCoin
* Search LeBonCoin for most recent ads in a specific region and topic.
* Returns the most recent classified ads in results, sorting by date (most recent first).
* Region identifiers : alsace, aquitaine, auvergne, basse_normandie, bourgogne, bretagne, centre,
* champagne_ardenne, corse, franche_comte, haute_normandie, ile_de_france, languedoc_roussillon,
* limousin, lorraine, midi_pyrenees, nord_pas_de_calais, pays_de_la_loire, picardie,
* poitou_charentes, provence_alpes_cote_d_azur, rhone_alpes, guadeloupe, martinique, guyane, reunion.
* 2014-07-22
*
* @name LeBonCoin
* @homepage http://www.leboncoin.fr
* @description Returns most recent results from LeBonCoin for a region and a keyword.
* @maintainer 16mhz
* @use1(r="Region identifier", k="Keyword")
*/
class LeBonCoinBridge extends BridgeAbstract{
public function collectData(array $param){
$html = '';
$link = 'http://www.leboncoin.fr/annonces/offres/' . $param[r] . '/?f=a&th=1&q=' . $param[k];
$html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404);
$list = $html->find('.list-lbc', 0);
$tags = $list->find('a');
foreach($tags as $element) {
$item = new \Item();
$item->uri = $element->href;
$title = $element->getAttribute('title');
$content = '<img src="' . $element->find('div.image', 0)->find('img', 0)->getAttribute('src') . '" alt="thumbnail">';
$date = $element->find('div.date', 0)->find('div', 0) . $element->find('div.date', 0)->find('div', 1) . '<br/>';
$detailsList = $element->find('div.detail', 0);
for ($i = 1; $i < 4; $i++) {
$line = $detailsList->find('div', $i);
$content .= $line;
}
$item->title = $title . ' - ' . $detailsList->find('div', 3);
$item->content = $content . $date;
$this->items[] = $item;
}
}
public function getName(){
return 'LeBonCoin';
}
public function getURI(){
return 'http://www.leboncoin.fr';
}
public function getCacheDuration(){
return 3600; // 1 hour
}
}