PHP 初学者 使用cURL访问http

 

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.sina.com.cn");
curl_setopt($ch, CURLOPT_HEADER, true);

// grab URL and pass it to the browser
$result = curl_exec($ch);
if ($result= true) {
 echo ($ch);
}

// close cURL resource, and free up system resources
curl_close($ch);
?>

地址栏中输入:

http://localhost/test/curl.php

出现:

HTTP/1.0 200 OK Date: Sun, 12 Oct 2008 10:21:53 GMT Server: Apache Last-Modified: Sun, 12 Oct 2008 10:21:04 GMT ETag: "5adcf-4590bbd670400" Accept-Ranges: bytes X-Powered-By: mod_xlayout_jh/0.0.1vhs.markIII.remix Cache-Control: max-age=60 Expires: Sun, 12 Oct 2008 10:22:53 GMT Vary: Accept-Encoding Content-Length: 384776 Content-Type: text/html Age: 56 X-Cache: HIT from 32-21.HP08020045.sina.com.cn Via: 1.0 32-21.HP08020045.sina.com.cn:80 (squid/2.6.STABLE13) Connection: close <script src="http://i3.sinaimg.cn/home/sinaflash.js" type=text/javascript></script> <script language=javascript src="http://d1.sina.com.cn/d1images/button/rotator.js" type=text/javascript></script> <script type=text/javascript> // 30) { alert("用户名非法,请检查!"); return false; }; if (password.length < 1 || password.length > 30) { alert("密码非法,请检查!"); return false; }; if(loginType == "null"){ alert("您还没有选择要登录到哪里,请您选择去向!"); sina.$("loginFldselectop").style.display = "block"; sina.addEvent(document.body,"mousedown",LoginSelectClickOther); return false; }; if(loginType == "263mail"){ document.form_04.u.value = username; document.form_04.psw.value = password; document.form_04.submit(); document.showLogin.password.value = ""; return false; }; if(username.indexOf("@")== -1 && loginType == "vipmail"){ document.showLogin.username.value += "@vip.sina.com"; }; document.showLogin.submit(); document.showLogin.password.value = ""; return false; } function chkLoginType(username){ username = username.toLowerCase(); if(username.indexOf("@") != -1){ sina.$("L_freemail").className = "disabled"; sina.$("L_freemail").onclick = null; sina.$("L_vipmail").className = "disabled"; sina.$("L_vipmail").onclick = null; sina.$("L_2008mail").className = "disabled"; sina.$("L_2008mail").onclick = null; sina.$("L_263mail").className = "disabled"; sina.$("L_263mail").onclick = null; }else{ sina.$("L_freemail").className = ""; sina.$("L_freemail").onclick = function(){LoginSelect("freemail")}; sina.$("L_vipmail").className = ""; sina.$("L_vipmail").onclick = function(){LoginSelect("vipmail")}; sina.$("L_2008mail").className = ""; sina.$("L_2008mail").onclick = function(){LoginSelect("2008mail")}; sina.$("L_263mail").className = ""; sina.$("L_263mail").onclick = function(){LoginSelect("263mail")}; return; }; if(username.indexOf("@sina.com") != -1){ sina.$("L_freemail").className = ""; sina.$("L_freemail").onclick = function(){LoginSelect("freemail")}; LoginSelect("freemail"); }; if(username.indexOf("@vip.sina.com") != -1){ sina.$("L_vipmail").className = ""; sina.$("L_vipmail").onclick = function(){LoginSelect("vipmail")}; LoginSelect("vipmail"); }; if(username.indexOf("@2008.sina.com") != -1){ sina.$("L_2008mail").className = ""; sina.$("L_2008mail").onclick = function(){LoginSelect("2008mail")}; LoginSelect("2008mail"); }; if(username.indexOf("@263.sina.com") != -1){ sina.$("L_263mail").className = ""; sina.$("L_263mail").onclick = function(){LoginSelect("263mail")}; LoginSelect("263mail"); }; }; var sina = { $ : function(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}, isIE : navigator.appVersion.indexOf("MSIE")!=-1?true:false, addEvent : function(obj,eventType,func){if(obj.attachEvent){obj.attachEvent("on" + eventType,func);}else{obj.addEventListener(eventType,func,false)}}, delEvent : function(obj,eventType,func){ if(obj.detachEvent){obj.detachEvent("on" + eventType,func)}else{obj.removeEventListener(eventType,func,false)} }, readCookie : function(l){var i="",I=l+"=";if(document.cookie.length>0){offset=document.cookie.indexOf(I);if(offset!=-1){offset+=I.length;end=document.cookie.indexOf(";",offset);if(end==-1)end=document.cookie.length;i=unescape(document.cookie.substring(offset,end))}};return i}, writeCookie : function(O,o,l,I){var i="",c="";if(l!=null){i=new Date((new Date).getTime()+l*3600000);i="; expires="+i.toGMTString()};if(I!=null){c=";domain="+I};document.cookie=O+"="+escape(o)+i+c} }; function LoginSelectClickOther(e){ thisObj = e.target?e.target:event.srcElement; do{ if(thisObj.id == "loginFldselect" || thisObj == document.showLogin.password) return; if(thisObj.tagName == "BODY"){LoginSelectClose();return;}; thisObj = thisObj.parentNode; }while(thisObj.parentNode); }; function clickLoginSelect(){ if(sina.$("loginFldselectop").style.display == "block"){ LoginSelectClose(); }else{ sina.$("loginFldselectop").style.display = "block"; sina.addEvent(document.body,"mousedown",LoginSelectClickOther); } }; function LoginSelectClose(){ sina.$("loginFldselectop").style.display = "none"; sina.delEvent(document.body,"mousedown",LoginSelectClickOther); }; function LoginSelect(title){ var titleName; switch(title){ case "freemail": document.showLogin.entry.value = "freemail"; titleName = "免费邮箱"; break; case "vipmail": document.showLogin.entry.value = "vipmail"; titleName = "VIP邮箱"; break; case "2008mail": document.showLogin.entry.value = "2008mail"; titleName = "2008邮箱"; break; case "263mail": document.showLogin.entry.value = "263mail"; titleName = "同名邮箱"; break; case "blog": document.showLogin.entry.value = "blog"; titleName = "博客"; break; case "vblog": document.showLogin.entry.value = "vblog"; titleName = "播客"; break; case "photo": document.showLogin.entry.value = "photo"; titleName = "相册"; break; case "space": document.showLogin.entry.value = "space"; titleName = "空间"; break; case "login": document.showLogin.entry.value = "sso"; titleName = "会员中心"; break; }; sina.$("loginFldselectdis").innerHTML = titleName; sina.writeCookie("loginType",title,2160,"sina.com.cn;path=/"); if(document.showLogin.username.value != "" && document.showLogin.password.value != ""){ document.showLogin.onsubmit(); }; LoginSelectClose(); }; function openLoginType(){ if(document.showLogin.username.value != "" && document.showLogin.username.value.indexOf("@") == -1 && sina.$("loginFldselectdis").innerHTML == "选择去向"){ sina.$("loginFldselectop").style.display = "block"; sina.addEvent(document.body,"mousedown",LoginSelectClickOther); } } //]]> </script> <script type=text/javascript> //35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'//w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('//b'+e(c)+'//b','g'),k[c]);return p}('r z=1g.1h.1i("1j")!=-1?I:9;s 6(h,j,k,l,m){5.1k="1.0";5.1l="1m";5.t=6.$(h);7(5.t==q){J B K("6(x)参数错误:x 对像存在!")};7(!6.u){6.u=B 1n()};5.x=6.u.v;6.u.17(5);5.1o=9;5.8=[];5.R=k==q?0:k;5.L=5.R;5.S=l==q?"1p":l;5.T=m==q?"":m;5.M=9;r n=U("6.u["+5.x+"].M = I");r o=U("6.u["+5.x+"].M = 9");7(z){5.t.C("V",n)}w{5.t.D("W",n,9)};7(z){5.t.C("X",o)}w{5.t.D("Y",o,9)};7(Z(j)!="1q"){j="1r"};j=j.1s();1t(j){N"V":5.y="W";E;N"X":5.y="Y";E;N"1u":5.y="1v";E;N"1w":5.y="1x";E;1y:5.y="1z"};5.18=s(a,b,c,d,e){7(6.$(a)==q){J B K("18(19)参数错误:19 对像存在!")};r f=5.8.v;7(c==""){c=q};5.8.17([a,b,c,d,e]);r g=U(/'6.u[/'+5.x+/'].F(/'+f+/')/');7(z){6.$(a).C("1A"+5.y,g)}w{6.$(a).D(5.y,g,9)};7(f==5.R){6.$(a).O=5.S;7(6.$(b)){6.$(b).A.P=""};7(c!=q){5.t.A.1a=c};7(d!=q){G(d)}}w{6.$(a).O=5.T;7(6.$(b)){6.$(b).A.P="1b"}};7(6.$(b)){7(z){6.$(b).C("V",n)}w{6.$(b).D("W",n,9)};7(z){6.$(b).C("X",o)}w{6.$(b).D("Y",o,9)}}};5.F=s(a){7(Z(a)!="10"){J B K("F(1c)参数错误:1c 不是 10 类型!")};r i;11(i=0;i<5.8.v;i++){7(i==a){6.$(5.8[i][0]).O=5.S;7(6.$(5.8[i][1])){6.$(5.8[i][1]).A.P=""};7(5.8[i][2]!=q){5.t.A.1a=5.8[i][2]};7(5.8[i][3]!=q){G(5.8[i][3])}}w 7(5.L==i){6.$(5.8[i][0]).O=5.T;7(6.$(5.8[i][1])){6.$(5.8[i][1]).A.P="1b"};7(5.8[i][4]!=q){G(5.8[i][4])}}};5.L=a};5.12=s(){7(H.v!=5.8.v){J B K("12()参数错误:参数数量与标签数量不符!")};r a=0,i;11(i=0;i=5.8.v){a=0};5.F(a)};5.1F=s(){1d(p);5.Q=9}};6.$=s(a){7(16.1f){15 G(/'16.1f("/'+a+/'")/')}w{15 G(/'16.1G./'+a)}}',62,105,'|||||this|SubShowClass|if|label|false|||||||||||||||||null|var|function|parentObj|childs|length|else|ID|eventType|isIE|style|new|attachEvent|addEventListener|break|select|eval|arguments|true|throw|Error|selectedIndex|mouseIn|case|className|display|autoPlay|defaultID|openClassName|closeClassName|Function|onmouseover|mouseover|onmouseout|mouseout|typeof|number|for|random|percent|spaceTime|return|document|push|addLabel|labelID|background|none|num|clearInterval|nextLabel|getElementById|navigator|appVersion|indexOf|MSIE|version|author|mengjia|Array|lock|selected|string|onmousedown|toLowerCase|switch|onclick|click|onmouseup|mouseup|default|mousedown|on|Math|5000|play|setInterval|stop|all'.split('|'),0,{})) /* ========== 舌签构造函数 end ========== */ try{document.execCommand('BackgroundImageCache', false, true);}catch(e){} //]]> </script> <script type=text/javascript> eval(function(p,a,c,k,e,r){e=function(c){return(c 35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'//w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('//b'+e(c)+'//b','g'),k[c]);return p}('11 1a=1b 1K();1a.2c=(1t 1c.1L!=/'1u/')&&(1t 1c.1L.2d!=/'1u/')&&(1t 2e!=/'1u/');1a.2f=16.1j?15:1k;1a.1M=(1N.1O.1P().19("2g")!=-1);1a.2h=(1N.1O.1P().19("2i")!=-1);10(1a.1M){1Q()}13 1Q(){1v.1w.1x("2j",13(){11 a=12.1y;1l(a.1z!=1)a=a.17;14 a});1v.1w.1x("1R",13(){11 a;10(12.1m=="1S")a=12.1T;18 10(12.1m=="1U")a=12.1y;10(!a)14;1l(a.1z!=1)a=a.17;14 a});1v.1w.1x("1V",13(){11 a;10(12.1m=="1U")a=12.1T;18 10(12.1m=="1S")a=12.1y;10(!a)14;1l(a.1z!=1)a=a.17;14 a})}13 1A(a,b){1l(a!=1d){a=a.17;10(a==b)14 15}14 1k}11 1e=1b 1K();11 1n;11 1B;11 1W=0;13 1C(a,b){10(a.19("1f")!=-1||a.19("1D")!=-1)a=a.1X(6);18 10(a.19("2k")!=-1)a=a.1X(4);18 a="";14 b+a}13 2l(){1E(11 i=0;i<1Y.1F;i++){11 d=1c.1G(1Y[i]);1o=d.1H("2m");1E(11 j=0;j<1o.1F;j++){11 e=1o[j];10(e.17.17!=d)2n;11 f=e.1H("a")[0];11 g=f.1p("1Z");11 h=f.1p("20");e.1g=13(a){10(a){12.1h="1f";12.1q=1C(12.1q,"1f")}18{12.1h="1D";12.1q=1C(12.1q,"1D")}};e.21=13(){12.1g(15);12.17.17.1i.1g(1k);12.17.17.1i=12;11 a=12.1H("a")[0];22(a.1p("1Z"),a.1p("20"))};e.2o=13(a){11 b=16.1r?16.1r:a;11 c=b.1R;10(1A(c,12)||c==12)14;10(12.1h=="1f")14;1B=12;23(1n);1n=16.2p("1B.21();",1W)};e.2q=13(a){11 b=16.1r?16.1r:a;11 c=b.1V;10(1A(c,12)||c==12)14;10(12.1h=="1f")14;23(1n)};10(g.19("#2r")!=-1){e.1g(15);d.1i=e;1e[g]=1I(h).1s}18{e.1g(1k)}}10(d.1i==1d)d.1i=1o[0]}}13 24(){11 a;10(16.1J){a=1b 1J();10(a.25){a.25("2s/2t")}}18 10(16.1j){26{a=1b 1j("2u.27")}28(e){26{a=1b 1j("2v.27")}28(e){}}}10(!a){16.2w("2x/'t 2y 1J 2z.");14 1d}14 a}13 29(a,b,c,d){11 e=1b 2A();11 f;11 i;e[0]="";e[1]="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";e[2]="a b c d e f g h i j k l m n o p q r s t u v w x y z";e[3]="0 1 2 3 4 5 6 7 8 9";10(!b&&!c&&!d){b=15;c=15;d=15}10(b){e[0]+=e[1]}10(c){e[0]+=" "+e[2]}10(d){e[0]+=" "+e[3]}e[0]=e[0].2B(" ");f="";1E(i=0;i <script type=text/javascript> function newbfring(aid,key,id){ var ringpre=window.open('http://bf.sina.com.cn/rng/'+aid+'_'+id+'_400.html'); window.open('http://bf.sina.com.cn/sinarc_php/srchring.php?from=400&aid='+aid+'&key='+key); ringpre.focus(); } function newbfring_t(aid,type,id){ var ringpre_t=window.open('http://bf.sina.com.cn/rng/'+aid+'_'+id+'_400.html'); window.open('http://bf.sina.com.cn/sinarc_php/ringlist.php?from=400&aid='+aid+'&type='+type); ringpre_t.focus(); } function newbfpic(type,aid,id){ var picpre=window.open('http://bf.sina.com.cn/pic/'+aid+'_'+id+'_400.html'); window.open('http://bf.sina.com.cn/sinarc_php/piclist.php?from=400&aid='+aid+'&type='+type); picpre.focus(); } function newyytype(type) { window.open('http://bf.sina.com.cn/sinarc_php/yycqlist.php?from=400&type='+type);} function newPlay(id,keyword){ cl_rbt=window.open('http://cl.sina.com.cn/newplay.php?from=400&id='+id,'play','width=650,height=430,resizable=1,scrollbars=0,status=no,toolbar=no,location=no,menu=no'); window.open('http://cl.sina.com.cn/newindex_search.php?searchtype=2&from=400&keyword='+keyword); cl_rbt.focus(); } </script> <script type=text/javascript> function iask(fn,strName){ if(fn.k.value=="" || fn.k.value=="请输入关键词"){fn.k.value="请输入关键词";fn.k.focus();return false;} if(strName == "blog"){ if(document.forms["iask_f"].t.selectedIndex==3){ fn.action="http://q.blog.sina.com.cn/group_search.php"; } else { if(document.forms["iask_f"].t.selectedIndex==2){ document.getElementById("s").value=0; fn.action="http://search.blog.sina.com.cn/blog/search"; } else { fn.action="http://search.blog.sina.com.cn/blog/search"; } //fn.action="http://search.blog.sina.com.cn/blog/search"; } } else { return false; } fn.submit(); return false; } function g(URL){window.location.href=URL;} </script> <script language=javascript type=text/javascript> // </script>

<script type=text/javascript> // </script> <script type=text/javascript> // </script>
<script src="http://woocall.sina.com.cn/rls/pusher/stable.js" type=text/javascript></script>
下面为新浪的网页. <script event=FSCommand(command,args) for=sina_suda_web_push_tunnel>sina_suda_web_push_tunnel_DoFSCommand(command, args);</script> <script type=text/javascript> // </script> <script src="http://i2.sinaimg.cn/unipro/pub/suda_m_v619.js" type=text/javascript></script> <script type=text/javascript>suds_init(41,1.00,965,2);</script> <script language=javascript src="http://d1.sina.com.cn/shh/2008TopBar/2008TopBar.js" type=text/javascript></script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值