Caomeipai.class.php 776 Bytes
<?php
/**
 * http://buy.caomeipai.com/
 */
class Util_Product_Api_Caomeipai extends Util_Product_Api
{
    public function getData($url)
    {
        $data = Util_Product_ApiConnect::get($url);
        if(!empty($data))
        {
            @phpQuery::newDocument($data);
            $doc = pq('#product');
            self::$product->name = trim(preg_replace('@<span (.*)</span>@isU', '', $doc->find('.product-name')->html()));
            self::$product->img = $doc->find('.product-bd img')->attr('src');
            self::$product->price = $doc->find('.price strong')->text();
            self::$product->imgs[] = self::$product->img;
        }
        else
        {
            throw new Util_Product_ApiException('请输入正确的商品地址!');
        }
    }
}