Beispiel #1
0
    /**
     * 下载图片到本地
     * @param $img_url
     * @return string
     */
    public function download_img($img_url)
    {
        $curl = curl_init($img_url);
        $filename = date('Ymdhis') . '_' . uniqid() . '.jpg';
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $imageData = curl_exec($curl);
        curl_close($curl);
        $tp = @fopen('img/' . $filename, 'a');
        fwrite($tp, $imageData);
        fclose($tp);
        return $filename;
    }
}
$spider = new Spider();
$spider->main();
//save_spot('http://www.lvmama.com/lvyou/d-chengdu279.html');
//$spider->save_view('http://www.lvmama.com/lvyou/poi/sight-151780.html', 1);
//$spider->save_spot('http://www.lvmama.com/lvyou/d-chengdu279.html');
/*
*
* 份1:d-sichuan278.html
景区页面1:http://www.lvmama.com/lvyou/scenery/d-sichuan278.html
景区URL1:http://www.lvmama.com/lvyou/d-chengdu279.html
景点URL1:http://www.lvmama.com/lvyou/poi/sight-151780.html
http://www.lvmama.com/lvyou/poi/sight-151780.html
*/