Itezhop.class.php 1.17 KB
<?php
/**
 *  http://www.itezhop.com/ezhop/itezhop/index/index.html
 */
class Util_Product_Api_Itezhop extends Util_Product_Api
{
    public function getData($url)
    {
        $data = Util_Product_ApiConnect::get($url);
        if(!empty($data))
        {
            phpQuery::$defaultCharset = 'gb2312';
            @phpQuery::newDocument($data);
            $doc = pq("#productdetail");
            self::$product->name =  $doc->find('h1')->text().$doc->find('#detail_brand')->text();
            self::$product->img = 'http://www.itezhop.com/'.$doc->find('img')->attr('src');
            self::$product->price = preg_replace('/\D+/','',$doc->find('#saleprice')->text());
            $length = pq("#mainslide")->find("img")->length();
           	for($i = 0; $i<$length; $i++)
           	{
           		$img = pq("#mainslide")->find("img")->eq($i)->attr('src');
           		self::$product->imgs [] = 'http://www.itezhop.com/'.str_replace('_S','_L', $img);
           	}
           	self::$product->imgs = array_values(array_unique(self::$product->imgs));
        }
        else
        {
            throw new Util_Product_ApiException('请输入正确的商品地址!');
        }
    }
}