php采集问题怎么回事就是采集不到呢高手来个?

b15365637 2018-09-29 06:09:26


function curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$contents = curl_exec($ch);
curl_close($ch);//关闭一打开的会话
return $contents;
}

$url = 'https://www.so.com/s?q=www.fwen.net';
$html = curl($url);
ECHO $html;



奇怪了就是采集不到怎么回事跪求
...全文
860 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2018-09-29
  • 打赏
  • 举报
回复
只是页面框架,内容都是 js 加载的
xuzuning 2018-09-29
  • 打赏
  • 举报
回复
<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie6"><![endif]-->
<!--[if IE 7 ]><html class="ie7"><![endif]-->
<!--[if IE 8 ]><html class="ie8"><![endif]-->
<!--[if IE 9 ]><html class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="always" name="referrer">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>www.fwen.net_360搜索</title>
<link rel="dns-prefetch" href="//p.ssl.qhimg.com"><link rel="dns-prefetch" href="//s.ssl.qhimg.com"><link rel="dns-prefetch" href="//s.ssl.qhres.com">
<link rel="dns-prefetch" href="//p418.ssl.qhimgs4.com"><link rel="dns-prefetch" href="//p419.ssl.qhimgs4.com"><link rel="dns-prefetch" href="//p420.ssl.qhimgs4.com">
<link rel="shortcut icon" href="https://s.ssl.qhres.com/static/52166db8c450f68d.ico" type="image/x-icon">
<link rel="search" type="application/opensearchdescription+xml" href="https://www.so.com/soopensearch.xml" title="360搜索">
<style type="text/css">body{background:#fff;color:#333;min-width:1000px;position:relative}body,th,td{font-family:arial}html,body,ul,ol,li,dl,dd,h1,h2,h3,h4,h5,h6,pre,form,input,button,textarea,p,th,td{margin:0;padding:0}p,form,ol,ul,li,h3,menu{list-style:none}table,img{border:0}img,object,select,input,textarea,button{vertical-align:middle}th{text-align:left}h1,h2,h3,h4,h5,h6,input,textarea,select,cite,em,i,b,strong,th{font-size:100%;font-style:normal}ins,s,u,del{text-decoration:none}em,cite{font-style:normal}em{color:#c00}input,button,select{color:#333}a em{text-decoration:underline}.f14{font-size:14px}.gray,a.gray{color:#666}.gray2,a.gray2{color:#999}.g-mask{background:rgba(0,0,0,0.7);height:100%;left:0;position:absolute;top:0;width:100%;z-index:800}.clearfix{zoom:1}.g-c-green{color:#19b955}.g-c-gray{color:#999}.g-c-dark{color:#666}.g-c-lightblue{color:#77c}.g-c-orange{color:#ff9600}.g-c-darkgreen{color:#4e9c62}.ie6 .g-mask,.ie7 .g-mask,.ie8 .g-mask{background:#000;filter:alpha(opacity=70)}.clearfix:after{clear:both;content:".";display:block;height:0;visibility:hidden}a.g-a-noline,.g-a-noline a,a.g-a-noline em,.g-a-noline a em{text-decoration:none}a.g-a-noline:hover,.g-a-noline a:hover,a.g-a-noline:hover em,.g-a-noline a:hover em{text-decoration:underline}.g-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.g-f-yahei{font-family:arial,"WenQuanYi Micro Hei","Microsoft YaHei",SimHei}.g-shadow{box-shadow:0 1px 1px rgba(0,0 ,0,0.06)}.g-clearfix{zoom:1}.g-card{border:1px solid #e5e5e5;font-size:13px;_zoom:1}.g-btn{border:0;border-radius:1px;box-sizing:content-box;cursor:pointer;display:inline-block;outline:none;overflow:hidden;padding:0 10px;text-align:center;text-decoration:none;vertical-align:middle}.g-btn-icon{display:inline-block;_padding-top:7px}.g-btn-green{background:#19b955;border:1px solid #19b955;color:#fff;font-size:12px;height:24px;line-height:24px}input.g-btn,button.g-btn{line-height:20px;*padding:0 5px}.g-clearfix:after{clear:both;content:'';display:block;height:0;visibility:hidden}.g-card .g-card-foot{border-top:1px solid #e5e5e5;height:36px;line-height:36px;padding:0 10px}.g-card .g-card-foot-open,.g-card .g-card-foot-close{padding:0}.g-btn-icon .g-icon{_margin-top:-3px}.g-btn-green:hover{background:#33cb63;border-color:#33cb63}.g-btn-green:active{background:#00ab36;border-color:#00ab36}.g-btn-green:visited{color:#fff}a.g-a-dark:link,.g-a-dark a:link{color:#666;text-decoration:none}a.g-a-dark:hover,.g-a-dark a:hover{color:#19b955;text-decoration:underline}a.g-a-lightblue:link,.g-a-lightblue a:link{color:#77c;text-decoration:none}a.g-a-lightblue:hover,.g-a-lightblue a:hover{color:#77c;text-decoration:underline}a.g-a-orange:link,.g-a-orange a:link{color:#ff9600;text-decoration:none}a.g-a-orange:hover,.g-a-orange a:hover{color:#ff9600;text-decoration:underline}.g-card .g-card-foot-open a,.g-card .g-card-foot-close a{color:#666;display:block;height:100%;_height:25px;_padding-top:10px;text-align:center;text-decoration:none;width:100%}.g-card .g-card-foot .g-icon{margin-top:-3px}.g-card .g-card-foot-open a:hover,.g-card .g-card-foot-close a:hover{color:#19b955}.g-btn-green:disabled,.g-btn-green-disabled,.g-btn-green-disabled:hover,.g-btn-green-disabled:visited{background:#fafafa;border-color:#eee;color:#aaa}.g-btn-green2{background:#fff;border:1px solid #19b955;font-size:12px;height:24px;line-height:24px}.g-btn-green2,.g-btn-green2:visited{color:#19b955}.g-btn-green2:hover{background:#1AC550;border-color:#33cb63;color:#fff}.g-btn-green2:active{background:#00ab36;border-color:#00ab36;color:#fff}.g-btn-green2:disabled,.g-btn-green2-disabled,.g-btn-green2-disabled:hover,.g-btn-green2-disabled:visited{background:#fafafa;border-color:#eee;color:#aaa}.g-btn-green3{background:#fff;border:1px solid #ccc;color:#333;font-size:12px;height:24px;line-height:24px}.g-btn-green3:hover{background:#fff;border-color:#19b955;color:#19b955}.g-btn-green3:active{background:#00ab36;border-color:#00ab36;color:#fff}.g-btn-green3:visited{color:#333}.g-btn-green3:disabled,.g-btn-green3-disabled,.g-btn-green3-disabled:hover,.g-btn-green3-disabled:visited{background:#fafafa;border-color:#eee;color:#aaa}.g-padding{padding-left:10px;padding-right:10px}.g-icon{display:inline-block;overflow:hidden;vertical-align:middle}.g-icon-arr,.g-icon-arr-left,.g-icon-arr-right,.g-icon-arr-up,.g-icon-arr-down{background-image:url(https://p.ssl.qhimg.com/t01054729d647fc0806.png);background-image:-webkit-image-set(url(https://p.ssl.qhimg.com/t01054729d647fc0806.png) 1x,url(https://p.ssl.qhimg.com/t01391279e4f7c1c44d.png) 2x)}.g-icon-arr-left{background-position:0 0;height:12px;width:7px}.g-icon-arr-right{background-position:-7px 0;height:12px;width:7px}.g-btn .g-icon{margin-right:5px}.g-icon-arr-down,.g-card-foot-open .g-icon-arr{background-position:-1px -20px;height:7px;width:12px}.g-icon-arr-up,.g-card-foot-close .g-icon-arr{background-position:-1px -13px;height:7px;width:12px}a:hover .g-icon-arr-left{background-position:0 -28px}a:hover .g-icon-arr-right{background-position:-7px -28px}a:hover .g-icon-arr-down,.g-card-foot-open a:hover .g-icon-arr{background-position:-1px -48px}a:hover .g-icon-arr-up,.g-card-foot-close a:hover .g-icon-arr{background-position:-1px -41px}.g-table{border-collapse:collapse;width:100%}.g-table-card{border:1px solid #e5e5e5}.g-menu{background:#fff;border:1px solid #e5e5e5;border-bottom:none;width:88px}.g-menu,.g-tip{font-size:12px;left:0;position:absolute;top:0}.g-tip{padding:5px 10px}.g-tip-default{background:#fff;border:1px solid #e5e5e5;color:#666}.g-tip-warning{background:#fffbf5;border:1px solid #ffe6c4;color:#ff9600}.g-tip-success{background:#f0fbf4;border:1px solid #c0eecf;color:#19b955}.g-tab{background:#f8f8f8;border:1px solid #e5e5e5;color:#666;height:34px}.g-page{border:1px solid #e5e5e5;border-right:0;display:inline-block;font-size:13px;height:34px;text-align:center;white-space:nowrap}.g-table th,.g-table td{border-bottom:1px solid #f5f5f5;font-size:13px;height:35px;line-height:35px}.g-menu li{border-bottom:1px solid #e5e5e5;height:30px;line-height:30px;white-space:nowrap}.g-tab li{cursor:pointer;float:left;font-size:13px;min-width:44px;padding:0 20px;text-align:center}.g-tab li,.g-page a,.g-page strong{border-right:1px solid #e5e5e5;height:34px;line-height:34px}.g-page a,.g-page strong{display:inline-block;font-weight:400;overflow:hidden;text-decoration:none;*vertical-align:middle;width:38px}.g-table thead th{background:#fafafa}.g-table thead th,.g-table tbody th{color:#999;font-weight:400}.g-menu li a{color:#666;display:block;height:100%;padding:0 0 0 20px;text-decoration:none}.g-page strong span{opacity:.35}.g-tab .g-tab-active{background:#fff;border-top:2px solid #19b955;color:#19b955;margin:-1px 0;position:relative}.g-page .g-page-curr{font-weight:700}.g-card-foot .g-page{border-top:0;border-bottom:0;height:36px}.g-page a:hover{background:#fafafa;color:#00bc3e}.g-page .g-page-pre span,.g-page .g-page-nxt span{margin-top:-3px;*margin-top:10px!important}.g-card-foot .g-page a,.g-card-foot .g-page strong{height:36px;line-height:36px}.g-table thead th:first-child,.g-table tbody th,.g-table thead th.g-table-first{padding-left:20px}.g-menu li a:hover{background:#19b955;color:#fff}#header{font-size:12px;min-width:980px;position:fixed;width:100%;z-index:3000}#head{float:left;font-size:12px;margin-top:11px}#header.shadow{box-shadow:0 0 5px #888}#header .inner{background:#fff;border-bottom:1px solid #ebebeb;min-width:1000px}#head .form{clear:both;margin-bottom:11px;position:relative;zoom:1}#head .round{background:#fff;border:1px solid #bbb;border-right:none;display:inline-block;height:36px;position:relative;vertical-align:top;width:539px}#head .input_key{-webkit-appearance:none;background:#fff;border:0;border-radius:0;font:16px/18px arial;height:18px;margin:10px 0 0 10px;outline:0;padding:0;position:relative;width:500px;z-index:1}#head .input_key::-ms-clear{display:none}#head .placeholder,-webkit-input-placeholder,-moz-placeholder{color:#999}.search-del{background-image:url(https://p.ssl.qhimg.com/d/inn/495719b6/del.png);background-repeat:no-repeat;background-position:5px 5px;background-image:-webkit-image-set(url(https://p.ssl.qhimg.com/d/inn/495719b6/del.png) 1x,url(https://p.ssl.qhimg.com/d/inn/8f48373a/del_2x.png) 2x);display:block;height:20px;overflow:hidden;position:absolute;right:8px;top:8px;width:20px;z-index:1}.s_site{padding-top:5px}.hd-rtools{display:none;position:absolute;right:10px;top:24px;z-index:202}.s_site input{margin:0;padding:0;vertical-align:middle}.s_site label{margin:0 18px 0 3px;vertical-align:middle}.search-del:hover{background-position:-15px 5px}.hd-rtools .show-bigscreen{display:none}.hd-rtools .menu{float:left;height:14px;line-height:14px}.hd-rtools .g-menu{display:none;top:22px}.hd-rtools .setting-list{left:-18px;width:76px}.hd-rtools .user-list{left:-15px;width:70px}.hd-rtools .engs-list{left:45px;width:76px}.hd-rtools .change{display:inline-block}.so-w1330 .hd-rtools,.so-w1330 .hd-rtools .show-bigscre
b15365637 2018-09-29
  • 打赏
  • 举报
回复
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in /www/web/weixinfx/public_html/00000.php on line 9
xuzuning 2018-09-29
  • 打赏
  • 举报
回复
给段久经考验的代码
    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'] . ' micromessenger');
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;
}
xuzuning 2018-09-29
  • 打赏
  • 举报
回复
302是跳转,你就跟着跳
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
b15365637 2018-09-29
  • 打赏
  • 举报
回复
引用 4 楼 xuzuning 的回复:
302是跳转,你就跟着跳
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);


http://v.fwen.net/00000.php 这样了
b15365637 2018-09-29
  • 打赏
  • 举报
回复
引用 2 楼 xuzuning 的回复:
只是页面框架,内容都是 js 加载的


http://v.fwen.net/00000.php 代码是原文
你修改了什么吗为什么我这边显示的是302

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧