首頁  >  文章  >  後端開發  >  php file_get_contents转curl抓取淘宝属性

php file_get_contents转curl抓取淘宝属性

WBOY
WBOY原創
2016-06-02 11:31:541153瀏覽

phpcurl

以下代码如何改为用 curl来抓取呢?并且以商品的IID保存
function get_shuxing($type,$iid){
if($type=='tmall'){
$text=file_get_contents("http://detail.tmall.com/item.htm?id=$iid");
preg_match('|

    (.*)
|isU',$text, $match);
}elseif ($type=='taobao'){
$text=file_get_contents("http://item.taobao.com/item.htm?id=$iid");
preg_match('|
    (.*)
|isU',$text, $match);
}
$match=$match[0];
$match = iconv('gbk', 'utf-8', $match);
echo $match;
}
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn