PHP读取京东商品图片

根据京东的商品链接取出商品图片

<?php
    $file_path='http://item.jd.com/1163375.html';
    $file_path='http://item.jd.com/11316517.html';
    $str=file_get_contents($file_path);
    
    $substr=strstr($str,'<img data-img="1" width="350"');
    if(strlen($substr)==0){
        $substr=strstr($str,' <img width="350" height="350"');
    }
    if(strlen($substr)!=0){
    $i=0;
    $j=0;
    while($i<8){
        if($substr[$j]=='"'){
            $i++;
        }
        echo $substr[$j++];
    }
    echo '/>';
    }
?>

 

posted @ 2014-08-02 21:41  picco  阅读(231)  评论(0)    收藏  举报