curl 抓取图片(PHP)
2009-07-26 00:48
239 查看
<?
$p="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/W020090504254969587296.jpg";
$t_url ="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/t662541.shtml";
$rs = file_get_pic($p);
echo $rs;
function file_get_pic($str) {
global $url_domin,$t_url;
$ch = curl_init();
//echo " <BR>".$from_url;
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0); //返回内容中包含 HTTP 头
//curl_setopt($ch,CURLOPT_POST,1);
$useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; QQDownload 1.7; TencentTraveler 4.0";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $t_url);
curl_setopt($ch,CURLOPT_COOKIESESSION,true);
//curl_setopt($ch,CURLOPT_COOKIE,"hiido_lv=1241423490703&hiido_ti=1241425695046&hiido_tod=4&hiido_ui=0.14425078706025363");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
//echo $t_url;
$str = curl_exec($ch);
curl_close($ch);
return $str;
}
?>
$p="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/W020090504254969587296.jpg";
$t_url ="http://news.cnhubei.com/hbrb/hbrbsglk/hbrb01/200905/t662541.shtml";
$rs = file_get_pic($p);
echo $rs;
function file_get_pic($str) {
global $url_domin,$t_url;
$ch = curl_init();
//echo " <BR>".$from_url;
curl_setopt($ch, CURLOPT_URL, $str);
curl_setopt($ch, CURLOPT_HEADER, 0); //返回内容中包含 HTTP 头
//curl_setopt($ch,CURLOPT_POST,1);
$useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; QQDownload 1.7; TencentTraveler 4.0";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, $t_url);
curl_setopt($ch,CURLOPT_COOKIESESSION,true);
//curl_setopt($ch,CURLOPT_COOKIE,"hiido_lv=1241423490703&hiido_ti=1241425695046&hiido_tod=4&hiido_ui=0.14425078706025363");
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
//echo $t_url;
$str = curl_exec($ch);
curl_close($ch);
return $str;
}
?>
相关文章推荐
- PHP通过CURL实现定时任务的图片抓取功能示例
- 一个PHP的远程图片抓取函数分享
- php通过curl添加cookie伪造登陆抓取数据的方法
- 结合PHP和CURL抓取远程网页数据
- php-curl获取接口图片地址,在php拼接img中无法访问,报403错误,在浏览器url中直接可以访问,html页面里img也可以访问
- php远程抓取网站图片并保存的代码
- php 抓取图片
- PHP抓取图片函数
- PHP Curl post上传图片版本不兼容而引起服务器端接收不到图片问题。
- php远程抓取网站图片并保存
- PHP中使用CURL发送get/post请求上传图片批处理功能
- php中CURL技术模拟登陆抓取数据实战,抓取某校教务处学生成绩。
- php抓取网页特定div区块及图片
- php 中使用cURL发送get/post请求,上传图片,批处理
- PHP的cURL库功能简介:抓取网页,POST数据及其他
- flash as3 抓取图片进行jpg编码压缩成jpg的ByteArray格式的二进制数据流发送到php
- 使用php方法curl抓取AJAX异步内容思路分析及代码分享
- PHP的CURL方法curl_setopt()函数案例介绍(抓取网页,POST数据)
- php 中使用cURL发送get/post请求,上传图片,批处理
- PHP中使用CURL伪造来路抓取页面或文件