Mbaobao.class.php
908 Bytes
<?php
/**
* http://www.mbaobao.com/
*/
class Util_Product_Api_Mbaobao extends Util_Product_Api
{
public function getData($url)
{
$data = Util_Product_ApiConnect::get($url);
if(!empty($data))
{
@phpQuery::newDocument($data);
$doc = pq('.item-detail');
self::$product->name = $doc->find('.goods-name')->text();
self::$product->price = intval($doc->find('.price-num')->text());
self::$product->img = $doc->find('#goods-zoom')->attr('href');
$length = $doc->find('.picture-smallpic')->find('a')->length();
for($i = 0 ;$i<$length; $i++)
{
$img = $doc->find('.picture-smallpic')->find('a')->eq($i)->attr('href');
self::$product->imgs[] = $img;
}
}
else
{
throw new Util_Product_ApiException('请输入正确的商品地址!');
}
}
}