关于cur采集 对方设置了来源页 本帖最后由 u013366173 于 2015-03-03 22:35:09 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 常用的功能要写成函数或类保存起来,以备不时之需而不是临阵擦枪include 'curl/curl_get.php';$url = 'http://miaoo.sinaapp.com/cai.php';echo curl_get($url);curl/curl_get.php<?phpfunction curl_get($durl, $data=array()) { $cookiejar = realpath('cookie.txt'); $t = parse_url($durl); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$durl); curl_setopt($ch, CURLOPT_TIMEOUT,5);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_ENCODING, 1); //gzip 解码 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);if($data) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data);} $r = curl_exec($ch); curl_close($ch); return $r;} <?php header('Content-Type:image/png');showAuthcode('http://miaoo.sinaapp.com/cai.php');function showAuthcode( $authcode_url ){ $ch = curl_init($authcode_url); curl_setopt($ch, CURLOPT_REFERER, "http://52jifenbao.com/cai/"); curl_exec($ch); curl_close($ch);}?>网上找到,解决了 刚开始学习php配置了apache后默认页面可以显示。但新建的a.php页面打开提示403错误 PHP报错 关于XML错误,高手请进 帮我注释一下这一小段程序,我看不懂 这个生成中文的有意思: 谁有最简单的用PHP写的两人聊天程序,高分求购。如果调度成功,立即给分。我说的两人聊天么当然就是指编程方便一点,最简单的只要能实现 请教如何在oa里面实现文档的全文检索? 看看错在哪? url中出现中文文件名,出错,怎么办? PHPADMIN怎么配置啊,不能用 多维数组如何按某个键进行排序? 关于通过淘宝商品ID获取商品资料API调用次数限制问题,求大神指教?
而不是临阵擦枪include 'curl/curl_get.php';
$url = 'http://miaoo.sinaapp.com/cai.php';
echo curl_get($url);
curl/curl_get.php<?php
function curl_get($durl, $data=array()) {
$cookiejar = realpath('cookie.txt');
$t = parse_url($durl);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$durl);
curl_setopt($ch, CURLOPT_TIMEOUT,5);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_ENCODING, 1); //gzip 解码
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if($data) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
<?php
header('Content-Type:image/png');
showAuthcode('http://miaoo.sinaapp.com/cai.php');
function showAuthcode( $authcode_url )
{
$ch = curl_init($authcode_url);
curl_setopt($ch, CURLOPT_REFERER, "http://52jifenbao.com/cai/");
curl_exec($ch);
curl_close($ch);
}
?>网上找到,解决了