Пример #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
 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);
 }
Пример #3
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);
 }
Пример #4
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);
 }