后台代码
function caiji(){
header("Content-type: text/html; charset=utf-8");
$url=$_POST['taobao_url'];
//$url="https://item.taobao.com/item.htm?spm=a21bo.2017.201867-rmds-15.3.5af911d9ZEcbiK&scm=1007.12807.84406.100200300000004&id=540021976353&pvid=07ca0d9b-36f5-4484-b816-8989542f8beb";
$text=file_get_contents($url);
$data=array();
//http://www.22.com/index.php?c=shop_market&act=caiji&datatype=json
//1运用正则抓取img标签中id为J_ImgBooth的img,$img[0]为该500图img标签,$img[1]为500图的图片地址;
preg_match('/]*id="J_ImgBooth"[^r]*rc="([^"]*)"[^>]*>/', $text, $img);
$data['img']= "http:".$img[1];
//var_dump($img[1]);
//2抓取商品名称
preg_match('/
$title1=iconv('GBK','UTF-8',$title[1]);
// var_dump($title1);
$data['name']=$title1;
//3商品价格
preg_match('/]*name="current_price" [^>]*>/', $text, $price);
$price1=explode('"',$price[0]);
//$price=floatval($price);//放入数据库估计还有转一下变量类型
$data['cost']=$price1[5];
//var_dump($price1[5]);
//4商品描述
preg_match_all('/



