示例#1
0
 public function import($feed)
 {
     // fetch HTML
     $xml = $this->_fetch($feed->url);
     // parse
     $stubs = array();
     $doc = @simplexml_load_string($xml);
     if ($doc === false) {
         throw new Yadda_Feed_Exception('Error parsing Citymob XML feed.');
     }
     foreach ($doc->deals->deal as $deal) {
         $stub = new Yadda_Feed_Stub();
         $stub->setGuid($this->_sanitize($deal->deal_url));
         $stub->setLink($this->_sanitize($deal->deal_url));
         $stub->setTitle($this->_sanitize($deal->short_title));
         $stub->setDescription($this->_sanitize($deal->title));
         $stub->setPrice((double) str_replace('ZAR', '', $deal->price));
         $stub->setValue((double) str_replace('ZAR', '', $deal->value));
         $stub->setDiscount((double) str_replace('ZAR', '', $deal->discount_percent));
         try {
             $stub->setGeo(array((double) $deal->vendor_latitude, (double) $deal->vendor_longitude));
         } catch (Yadda_Feed_Exception $e) {
             // ignore
         }
         $stub->addImage($this->_sanitize($deal->large_image_url));
         $stubs[] = $stub;
     }
     return $stubs;
 }
示例#2
0
文件: Cotd.php 项目: neilgarb/yadda
 public function import($feed)
 {
     // fetch
     $xml = $this->_fetch($feed->url);
     // parse
     $xml = new SimpleXMLElement($xml);
     $stubs = array();
     foreach ($xml->xpath('/deals/deal') as $deal) {
         $stub = new Yadda_Feed_Stub();
         $res = $deal->xpath('ID');
         $stub->setGuid('cotd/' . intval($res[0]));
         $res = $deal->xpath('title');
         $stub->setTitle($this->_sanitize((string) $res[0]));
         $res = $deal->xpath('url');
         $stub->setLink($this->_sanitize((string) $res[0]));
         $res = $deal->xpath('description');
         $stub->setDescription($this->_sanitize((string) $res[0]));
         $res = $deal->xpath('image');
         $stub->addImage($this->_sanitize((string) $res[0]));
         $res = $deal->xpath('value');
         $stub->setValue((double) $res[0]);
         $res = $deal->xpath('price');
         $stub->setPrice($res[0]);
         $stub->setDiscount(($stub->getValue() - $stub->getPrice()) / $stub->getValue() * 100);
         $stubs[] = $stub;
     }
     return $stubs;
 }
示例#3
0
 public function import($feed)
 {
     // download
     $html = $this->_fetch($feed->url);
     // parse
     $stub = new Yadda_Feed_Stub();
     // guid + link
     $link = $this->_match('#<h1>\\s*<a href="/([^"]+)".*>\\s*</h1>#sU', $html);
     if ($link !== null) {
         $stub->setGuid('http://www.dealify.com/' . $this->_sanitize($link));
         $stub->setLink('http://www.dealify.com/' . $this->_sanitize($link));
     }
     // title
     $title = $this->_match('#<title>(.*)</title>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div id="deal_description">(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<span>from.*</span>.*<strong>R(\\d+)</strong>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // value
     $value = $this->_match('#<span>value.*</span>.*<strong class="grey">R(\\d+)</strong>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     $discount = $this->_match('#<span>save.*</span>.*<strong class="grey">(\\d+)%</strong>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // geo
     $lat = $this->_match('#>Lat: ([\\-\\d\\.]+)<#sU', $html);
     $long = $this->_match('#>Long: ([\\-\\d\\.]+)<#sU', $html);
     if ($lat !== null && $long !== null) {
         $stub->setGeo(array((double) $lat, (double) $long));
     }
     // image
     $image = $this->_match('#<div class="frame" id="main_picture_frame">.*<img.*<img.*src="([^"]+)".*</div>#sU', $html);
     if ($image !== null) {
         $stub->addImage('http://www.dealify.com' . $this->_sanitize($image));
     }
     return array($stub);
 }
示例#4
0
文件: Zappon.php 项目: neilgarb/yadda
 public function import($feed)
 {
     $return = array();
     // get the HTML
     $html = $this->_fetch($feed->url);
     // parse the HTML
     $liMatches = array();
     @preg_match_all('#<li>(.*)</li>#sU', $html, $liMatches);
     foreach ($liMatches[1] as $liMatch) {
         $stub = new Yadda_Feed_Stub();
         // title + link
         $pMatches = array();
         @preg_match_all('#<p class="clsRecentDealHd">.*<a href="([^"]+)".*>([^<]+)</a></p>#sU', $liMatch, $pMatches);
         if (sizeof($pMatches[0]) == 0) {
             continue;
         }
         $link = 'http://www.zappon.co.za' . $this->_sanitize($pMatches[1][0]);
         $stub->setGuid($link);
         $stub->setLink($link);
         $title = $this->_sanitize($pMatches[2][0]);
         $stub->setTitle($title);
         // description
         $description = $this->_getDescription($link);
         if (!empty($description)) {
             $stub->setDescription($description);
         }
         // price
         $price = $this->_match('#<p class="bought-count">R<span class="c cr" title=".*>(\\d+)</span></p>#sU', $liMatch);
         if ($price !== null) {
             $stub->setPrice((double) $price);
         }
         // value
         $value = $this->_match('#<span>Value : R<span class="c cr" title="[^"]+">(\\d+)</span>#sU', $liMatch);
         if ($value !== null) {
             $stub->setValue((double) $value);
         }
         // discount
         $discount = $this->_match('#<span>Discount : <span class="c1" title="[^"]+">(\\d+)</span>%</span>#sU', $liMatch);
         if ($discount !== null) {
             $stub->setDiscount((double) $discount);
         }
         // image
         $image = $this->_match('#<img.*src="([^"]+)"#sU', $liMatch);
         if ($image !== null) {
             $stub->addImage('http://www.zappon.co.za' . $this->_sanitize($image));
         }
         $return[] = $stub;
     }
     return $return;
 }
示例#5
0
文件: Skoop.php 项目: neilgarb/yadda
 public function import($feed)
 {
     $stub = new Yadda_Feed_Stub();
     // fetch the listing page
     $html = $this->_fetch($feed->url);
     // link + guid
     $link = $this->_match('#<div class="main_price">.*</div>.*<a href="(.*)">.*<div id="buy_now_btn"#sU', $html);
     if ($link !== null) {
         $stub->setGuid('http://www.skoop.co.za' . $this->_sanitize($link));
         $stub->setLink('http://www.skoop.co.za' . $this->_sanitize($link));
     }
     // title
     $title = $this->_match('#<h1>(.*)</h1>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div id="long_desc" class="deal_description".*>(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<div class="main_price">.*R (.*)\\s*</div>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) str_replace(',', '', $price));
     }
     // value
     $value = $this->_match('#value <br />.*<span class="larger">R ([\\d\\,\\.]+)</span>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) str_replace(',', '', $value));
     }
     // discount
     $discount = $this->_match('#discount <br />.*<span class="larger">(\\d+)%</span>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // image
     $image = $this->_match('#<img src="([^"]+)"  class="main_deal" />#sU', $html);
     if ($image !== null) {
         $stub->addImage($this->_sanitize($image));
     }
     // geo
     $geo = $this->_match('#google.maps.LatLng\\((.*)\\)#sU', $html);
     if ($geo !== null) {
         $geo = str_replace("'", '', $geo);
         $stub->setGeo(array_map('floatval', explode(', ', $geo)));
     }
     return array($stub);
 }
示例#6
0
 public function import($feed)
 {
     // download
     $html = $this->_fetch($feed->url, false, true);
     // parse
     $stub = new Yadda_Feed_Stub();
     // guid
     $id = $this->_match('#product/(\\d+)/\' id="scriptbuynow"#sU', $html);
     if ($id !== null) {
         $stub->setGuid('mobstir/' . $id);
         $stub->setLink('http://www.mobstir.co.za/?id=' . $id);
     }
     // title
     $title = $this->_match('#<meta name="description" content="([^"]+)" />#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div class="des-panel">.*<h3>description</h3>(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // value
     $value = $this->_match('#value.*<h3>.*R (\\d+)\\s+</h3>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     $discount = $this->_match('#discount.*<h3>(\\d+)%</h3>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // price
     $price = $this->_match('#R([\\d\\.]+)#', $stub->getTitle());
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // image
     $image = $this->_match('#<div class="banner_middle.*background: url\\(([^\\)]+)\\)#sU', $html);
     if ($image !== null) {
         $stub->addImage($this->_sanitize($image));
     }
     return array($stub);
 }
示例#7
0
 public function import($feed)
 {
     $stub = new Yadda_Feed_Stub();
     // fetch the page
     $html = $this->_fetch($feed->url);
     // link + guid
     $link = $this->_match('#<fb:like href="([^"]+)"#sU', $html);
     if ($link !== null) {
         $stub->setGuid($this->_sanitize($link));
         $stub->setLink($this->_sanitize($link));
     }
     // title
     $title = $this->_match('#<span id="lblName">([^<]+)</span>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<a name="Deal"></a>Here\'s the Deal!(.*)<div#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<span id="lblSitePrice" class="SitePrice">R ([\\d\\.]+)</span>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // value
     $value = $this->_match('#<span id="ProductDealControl1_lblValue">R ([\\d\\.]+)</span>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     $discount = $this->_match('#<span id="ProductDealControl1_lblDiscount">(\\d+)%</span>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // image
     $image = $this->_match('#<img alt="[^"]+".*src="([^"]+)" /></div>#sU', $html);
     if ($image !== null) {
         $stub->addImage($this->_sanitize($image));
     }
     // return
     return array($stub);
 }
示例#8
0
 public function import($feed)
 {
     $stub = new Yadda_Feed_Stub();
     // fetch
     $html = $this->_fetch($feed->url);
     // link
     $stub->setLink($feed->url);
     // guid
     $guid = $this->_match('#did=([^\']+)\'#s', $html);
     if ($guid !== null) {
         $stub->setGuid('247deals/' . $guid);
     }
     // title
     $title = $this->_match('#<h1 id="deal_title"><a href=.*>(.*)</a></h1>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div class="tab_second_content">(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<div id="buynow_price">R([^<]+)</div>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // value
     $value = $this->_match('#Value<br />.*<span>.*R(\\d+)</span>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     $discount = $this->_match('#Discount<br />.*<span>.*(\\d+)%</span>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // image
     $image = $this->_match('#<div class="panel" title="1".*src="([^"]+)"#sU', $html);
     if ($image !== null) {
         $stub->addImage('http://247deals.co.za/' . $image);
     }
     return array($stub);
 }
示例#9
0
 public function import($feed)
 {
     // download feed
     $html = $this->_fetch($feed->url, true);
     // parse
     $stub = new Yadda_Feed_Stub();
     // link + guid
     $link = $this->_match('#<fb:like href="([^"]+)"#sU', $html);
     if ($link !== null) {
         $stub->setGuid($this->_sanitize($link));
         $stub->setLink($this->_sanitize($link));
     }
     // title
     $title = $this->_match('#<h1 class="deal-title">([^<]+)</h1>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div class="highlights">.*<h3>Highlights</h3>(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<div class=\'price\'>R([\\d\\.]+)</div>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // value
     $value = $this->_match('#<tr>.*<td>R([\\d\\.]+)</td>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     $discount = $this->_match('#<tr>.*<td>(\\d+)%</td>#sU', $html);
     if ($discount !== null) {
         $stub->setDiscount((double) $discount);
     }
     // image
     $image = $this->_match('#<div class="worklet-content"><img.*src="([^"]+)"#sU', $html);
     if ($image !== null) {
         $stub->addImage($this->_sanitize($image));
     }
     return array($stub);
 }
示例#10
0
 public function import($feed)
 {
     $stub = new Yadda_Feed_Stub();
     // fetch
     $html = $this->_fetch($feed->url);
     // link
     $stub->setLink('http://www.onedayonly.co.za/');
     // guid
     $guid = $this->_match('#<input type="hidden" name="product_id" value="([^"]+)" />#sU', $html);
     if ($guid !== null) {
         $stub->setGuid('onedayonly/' . $guid);
     }
     // title
     $title = $this->_match('#<td.*class="product_name".*>([^<]+)</td>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div class="product_s_desc">(.*)</td>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<span class="productPrice">([^<]+)</span>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) str_replace('R', '', trim($price)));
     }
     // value
     $value = $this->_match('#Retail price: <s>R([\\d\\.]+)</s>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     if ($stub->getValue() !== null && $stub->getPrice() !== null && $stub->getValue() > 0) {
         $stub->setDiscount(($stub->getValue() - $stub->getPrice()) / $stub->getValue() * 100);
     }
     // image
     $image = $this->_match('#<a.*rel="lightbox"><img src="([^"]+)" class="browseProductImage"#sU', $html);
     if ($image !== null) {
         $stub->addImage($this->_sanitize($image));
     }
     return array($stub);
 }
示例#11
0
 public function import($feed)
 {
     $stub = new Yadda_Feed_Stub();
     // fetch
     $html = $this->_fetch($feed->url);
     // link + guid
     $link = $this->_match('#<meta name="og:url" content="([^"]+)" />#sU', $html);
     if ($link !== null) {
         $stub->setLink($this->_sanitize($link));
         $stub->setGuid($this->_sanitize($link));
     }
     // title
     $title = $this->_match('#<h1>([^<]+)</h1>#sU', $html);
     if ($title !== null) {
         $stub->setTitle($this->_sanitize($title));
     }
     // description
     $description = $this->_match('#<div class="product-details".*>(.*)</div>#sU', $html);
     if ($description !== null) {
         $stub->setDescription($this->_sanitize($description));
     }
     // price
     $price = $this->_match('#<div class="price">([^<]+)</div>#sU', $html);
     if ($price !== null) {
         $stub->setPrice((double) $price);
     }
     // value
     $value = $this->_match('#<span class="rrp">R.*([\\d\\.]+)</span>#sU', $html);
     if ($value !== null) {
         $stub->setValue((double) $value);
     }
     // discount
     if ($stub->getPrice() !== null && $stub->getValue() !== null && $stub->getValue() > 0) {
         $stub->setDiscount(($stub->getValue() - $stub->getPrice()) / $stub->getValue() * 100);
     }
     // image
     $image = $this->_match('#<img id="MainPic".*src="([^"]+)"#sU', $html);
     if ($image !== null) {
         $stub->addImage('http://www.24hoursonly.co.za/' . $image);
     }
     return array($stub);
 }
示例#12
0
 public function import($feed)
 {
     // fetch
     $html = $this->_fetch($feed->url);
     // parse
     $stub = new Yadda_Feed_Stub();
     $link = $this->_sanitize($this->_match('#<fb:comments.*href="([^"]+)".*></fb:comments>#sU', $html));
     $stub->setLink($link);
     $stub->setGuid($link);
     $stub->setTitle($this->_sanitize($this->_match('#<h1>Today\'s Deal: <span>([^<]+)</span></h1>#sU', $html)));
     $stub->setPrice((double) $this->_match('#<span class="price_value" id="price_value-1">R(\\d+)  </span>#sU', $html));
     $stub->setValue((double) $this->_match('#<h3>Value</h3>.*<span>R(\\d+)</span>#sU', $html));
     $stub->setDiscount((double) $this->_match('#<h3>Discount</h3>.*<span>(\\d+)%</span>#sU', $html));
     $stub->addImage($this->_sanitize($this->_match('#<div class="banner_middle".*>.*<img src="([^"]+)"#sU', $html)));
     $geo = $this->_match('#&amp;ll=([\\-\\d\\.,]+)&#sU', $html);
     if ($geo !== null) {
         $stub->setGeo(array_map('floatval', explode(',', $geo)));
     }
     return array($stub);
 }
示例#13
0
 public function import($feed)
 {
     // fetch
     $html = $this->_fetch($feed->url);
     // parse
     $matches = array();
     @preg_match_all('#<div class="main-deal">.*<h2><a.*href="([^"]+)".*>([^<]*)</a>' . '</h2>.*<span class="price-main">R([\\d\\.]+)</span>.*<span class="price-savings">' . 'save (\\d+)%</span>.*Value<br /><b>R(\\d+)</b>.*<div class="main-deal-right">.*' . '<img src="([^"]+)".*<div class="more-content-left">(.*)<div class="more-content-right">#sU', $html, $matches);
     if (sizeof($matches[0]) == 0) {
         return array();
     }
     $stub = new Yadda_Feed_Stub();
     $stub->setGuid('http://www.vuzuplaza.com' . $this->_sanitize($matches[1][0]));
     $stub->setLink('http://www.vuzuplaza.com' . $this->_sanitize($matches[1][0]));
     $stub->setTitle($this->_sanitize($matches[2][0]));
     $stub->setDescription($this->_sanitize($matches[7][0]));
     $stub->setPrice((double) $matches[3][0]);
     $stub->setDiscount((double) $matches[4][0]);
     $stub->setValue((double) $matches[5][0]);
     $stub->addImage('http://www.vuvuplaza.com' . $this->_sanitize($matches[6][0]));
     return array($stub);
 }
示例#14
0
 public function import($feed)
 {
     // get html
     $html = $this->_fetch($feed->url);
     // parse
     $stubs = array();
     $matches = array();
     preg_match_all('#<div class="box">.*<div class="apollo_title">.*<a href="([^"]+)".*>([^<]+)</a>.*Saving you.*R([\\d,]+) </div>.*<b>R([\\d,]+) </b>.*<b>(\\d+)<b>%.*<div class="avatar">.*<img src="([^"]+)"#sU', $html, $matches);
     for ($i = 0; $i < sizeof($matches[0]); $i++) {
         $stub = new Yadda_Feed_Stub();
         $stub->setLink('http://www.bwu.co.za' . $this->_sanitize($matches[1][$i]));
         $stub->setGuid('http://www.bwu.co.za' . $this->_sanitize($matches[1][$i]));
         $stub->setTitle($this->_sanitize($matches[2][$i]));
         $savings = (double) str_replace(',', '.', $matches[3][$i]);
         $value = (double) str_replace(',', '.', $matches[4][$i]);
         $stub->setValue($value);
         $stub->setPrice($value - $savings);
         $stub->setDiscount((double) str_replace(',', '.', $matches[5][$i]));
         $stub->addImage('http://www.bwu.co.za' . $this->_sanitize($matches[6][$i]));
         $stubs[] = $stub;
     }
     return $stubs;
 }