Example #1
0
 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;
 }
Example #2
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;
 }
Example #3
0
 public function import($feed)
 {
     $stubs = array();
     // fetch
     $html = $this->_fetch($feed->url);
     // parse
     $content = $this->_match('/<div id="content" class="grid_12">(.*)<\\/div><!-- end #content-->/sU', $html);
     if ($content !== null) {
         $matches = array();
         preg_match_all('#<div class="info-box deal-listing">.*<img src="([^"]+)" class="floatleft".*<h3><a href="([^"]+)".*>([^<]+)<.*Price: R([0-9]+) \\|.*((<p>.*</p>)+).*</div>#sU', $content, $matches);
         for ($i = 0; $i < sizeof($matches[0]); $i++) {
             $stub = new Yadda_Feed_Stub();
             // link
             $stub->setLink('http://www.collectivecow.com' . $this->_sanitize($matches[2][$i]));
             // guid
             $stub->setGuid('http://www.collectivecow.com' . $this->_sanitize($matches[2][$i]));
             // title
             $stub->setTitle($this->_sanitize($matches[3][$i]));
             // description
             $stub->setDescription($this->_sanitize($matches[5][$i]));
             // price
             $stub->setPrice((double) $matches[4][$i]);
             // image
             $stub->addImage('http://www.collectivecow.com' . $this->_sanitize($matches[1][$i]));
             $stubs[] = $stub;
         }
     }
     return $stubs;
 }
Example #4
0
 public function import($feed)
 {
     $stubs = array();
     // fetch
     $html = $this->_fetch($feed->url);
     // parse
     $matches = array();
     preg_match_all('#<div class="side1">.*<img src="(/img/medium_big_thumb[^"]+)".*<h3>Description</h3>(.*)</div>.*</div>.*<div class="side2">.*([0-9]+)" title="Buy".*<p class="price"><span>R<span class="c cr"[^>]+>([0-9\\.]+)</span></span></p>.*</div>#sU', $html, $matches);
     for ($i = 0; $i < sizeof($matches[0]); $i++) {
         $stub = new Yadda_Feed_Stub();
         // link
         $stub->setLink($feed->url);
         // guid
         $id = (int) $matches[3][$i];
         $stub->setGuid('justhenga/' . $id);
         // description
         $stub->setDescription($this->_sanitize($matches[2][$i]));
         // price
         $stub->setPrice((double) $matches[4][$i]);
         // title
         $stub->setTitle(substr($stub->getDescription(), 0, 50) . '... (R' . sprintf('%.2f', $stub->getPrice()) . ')');
         // image
         $stub->addImage('http://www.justhenga.com' . $this->_sanitize($matches[1][$i]));
         $stubs[] = $stub;
     }
     return $stubs;
 }
Example #5
0
 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;
 }
Example #6
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);
 }
Example #7
0
 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);
 }
Example #8
0
 public function import($feed)
 {
     // download XML
     try {
         $xml = $this->_fetch($feed->url);
         $rss = Zend_Feed::importString($xml);
     } catch (Exception $e) {
         throw new Yadda_Feed_Exception('Error getting feed: ' . (string) $e);
     }
     $stubs = array();
     // iterate over each entry
     foreach ($rss as $entry) {
         $stub = new Yadda_Feed_Stub();
         $guid = $entry->guid();
         if (empty($guid)) {
             $guid = $entry->link();
         }
         $stub->setGuid($guid);
         $title = trim(html_entity_decode($entry->title(), ENT_QUOTES, 'utf-8'));
         $stub->setTitle($title);
         $stub->setLink($entry->link());
         $description = trim(html_entity_decode(strip_tags($entry->description()), ENT_QUOTES, 'utf-8'));
         if (!empty($description)) {
             $stub->setDescription($description);
         }
         $date = $entry->pubDate();
         if (!empty($date)) {
             $stub->setDate(date('Y-m-d H:i:s', strtotime($date)));
         }
         $price = $this->_getPrice($title . ' ' . (string) $description);
         if ($price !== null) {
             $stub->setPrice($price);
         }
         // images
         $description = $entry->description();
         if (!empty($description)) {
             $matches = array();
             preg_match_all('#src="(https?://[^"]+)"#', $description, $matches);
             if (isset($matches[1]) && sizeof($matches[1]) > 0) {
                 $stub->addImage($matches[1][0]);
             }
         }
         $stubs[] = $stub;
     }
     return $stubs;
 }
Example #9
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);
 }
Example #10
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);
 }
Example #11
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);
 }
Example #12
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);
 }
Example #13
0
 public function import($feed)
 {
     $stubs = array();
     // select city
     $retries = 3;
     for ($i = 0; $i < $retries; $i++) {
         try {
             $config = Zend_Registry::get('config');
             $client = new Zend_Http_Client($feed->url, array('useragent' => $config->userAgent, 'timeout' => 20));
             $client->setCookieJar(true);
             $client->request();
             // success!
             break;
         } catch (Zend_Http_Exception $e) {
             // if last retry fails, throw error
             if ($i == $retries - 1) {
                 throw new Yadda_Feed_Exception('Error selecting city.');
             }
         }
         // retry
         sleep(1);
     }
     // fetch home page
     try {
         $client->setUri('https://www.daddysdeals.co.za/');
         $response = $client->request();
     } catch (Zend_Http_Exception $e) {
         throw new Yadda_Feed_Exception('Error downloading feed.');
     }
     $html = $response->getBody();
     $matches = array();
     @preg_match_all('#<div class="deal-content">.*<h1><a href="([^"]+)"[^>]*>(.*)</a>.*<div class="deal-gallery">.*<img src="([^"]+)".*<div class="deal-info-buy">.*<span>R([0-9\\.]+)</span>.*</div>.*<div class="deal-content-highlights">.*<h3>At a glance</h3>(.*)</div>.*</div>#sU', $html, $matches);
     for ($i = 0; $i < sizeof($matches[0]); $i++) {
         $stub = new Yadda_Feed_Stub();
         $stub->setLink($this->_sanitize($matches[1][$i]));
         $stub->setGuid($this->_sanitize($matches[1][$i]));
         $stub->setTitle($this->_sanitize($matches[2][$i]));
         $stub->addImage($this->_sanitize($matches[3][$i]));
         $stub->setPrice((double) $matches[4][$i]);
         $stub->setDescription($this->_sanitize($matches[5][$i]));
         $stubs[] = $stub;
     }
     return $stubs;
 }
Example #14
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);
 }
Example #15
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);
 }
Example #16
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);
 }
Example #17
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);
 }
Example #18
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;
 }