Nala.class.php
978 Bytes
<?php
/**
* http://www.nala.com.cn/
*/
class Util_Product_Api_Nala extends Util_Product_Api
{
public function getData($url)
{
$data = Util_Product_ApiConnect::get($url);
if(!empty($data))
{
@phpQuery::newDocument($data);
$doc = pq(".detail");
self::$product->name = trim($doc->find('h2')->text());
self::$product->img = pq('.pic_view')->find('img')->attr('src');
self::$product->price = trim($doc->find('em')->eq(1)->text());
$length = pq('#item-thumbs')->find("img")->length();
for($i = 0; $i<$length; $i++)
{
self::$product->imgs[] = pq('#item-thumbs')->find("img")->eq($i)->attr("data-view");
}
self::$product->imgs = array_values(array_unique(self::$product->imgs));
}
else
{
throw new Util_Product_ApiException('请输入正确的商品地址!');
}
}
}