复制代码 代码如下:
/*
author: ssh_kobe
date: 20110602
shortage: 如果网页中的图片路径不是绝对路径,就无法抓取
*/
set_time_limit(0);//抓取不受时间限制
$URL='http://pp.baidu.com/';//任意网址
get_pic($URL);
function get_pic($pic_url) {
//获取图片二进制流
$data=CurlGet($pic_url);
/*利用正则表达式得到图片链接*/
$pattern_src = '//';
$num = preg_match_all($pattern_src, $data, $match_src);
$arr_src=$match_src[1];//获得图片数组
get_name($arr_src);
echo "
finished!!!";
return 0;
}
/*得到图片类型,并将其保存到与该文件同一目录*/
function get_name($pic_arr)
{
//图片类型
$pattern_type = '/(/.(jpg|bmp|jpeg|gif|png))/';
foreach($pic_arr as $pic_item){//循环取出每幅图的地址
$num = preg_match_all($pattern_type, $pic_item, $match_type);
$pic_name = get_unique().$match_type[1][0];//改时微秒时间戳命名
//以流的形式保存图片
$write_fd = @fopen($pic_name,"wb");
@fwrite($write_fd, CurlGet($pic_item));
@fclose($write_fd);
echo "[OK]..!";
}
return 0;
}
//通过微秒时间获得唯一ID
function get_unique(){
list($msec, $sec) = explode(" ",microtime());
return $sec.intval($msec*1000000);
}
//抓取网页内容
function CurlGet($url){
$url=str_replace('&','&',$url);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
//curl_setopt($curl, CURLOPT_REFERER,$url);
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; SeaPort/1.2; Windows NT 5.1; SV1; InfoPath.2)");
curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
$values = curl_exec($curl);
curl_close($curl);
return $values;
}
?>

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

WebStorm Mac版
好用的JavaScript开发工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能