900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > PHP中使用CURL获取页面title例子 curltitle

PHP中使用CURL获取页面title例子 curltitle

时间:2022-04-09 11:00:21

相关推荐

PHP中使用CURL获取页面title例子 curltitle

php教程|php手册

PHP,CURL,页面,title,

php教程-php手册

PHP中使用CURL获取页面title例子,curltitle

哪个夺宝源码好,硬盘安装ubuntu镜像,tomcat搭建成功404,Python爬虫怎么,php人员管理实战,河源抖音短视频seo怎么做lzw

通过PHP获取页面title内容的实战演示:

php旅游源码下载,vscode不安全代码,史上最全ubuntu,tomcat支持大并发,node小说爬虫,php call方法,东营seo优化专业哪个好,集团网站源代码,微信公众号静态html模板下载lzw

范例代码:

e4a全套源码,vscode未找到命名空间,ubuntu 混合硬盘,tomcat多窗口启动,爬虫接口网站,php sap rfc,运城seo抖音搜索排名,电子商务网站 php,帝国cms模板免费lzw

复制代码 代码如下:

<?php

/*

功能: 取得 URL 页面上的

内容<p>参数:$_POST[‘url’]<p>*/</p><p>// 设置最长执行的秒数<p>ini_set (“expect.timeout”, 30);<p>set_time_limit(30);</p><p>// 检查 URL<p>if(!isset($_POST[‘url’]) || $_POST[‘url’] == ”){<p>echo “URL 错误”;<p>exit;<p>}</p><p>/* 取得 URL 页面数据 */<p>// 初始化 CURL<p>$ch = curl_init();</p><p>// 设置 URL<p>curl_setopt($ch, CURLOPT_URL, $_POST[‘url’]);<p>// 让 curl_exec() 获取的信息以数据流的形式返回,而不是直接输出。<p>curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);<p>// 在发起连接前等待的时间,如果设置为0,则不等待<p>curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);<p>// 设置 CURL 最长执行的秒数<p>curl_setopt ($ch, CURLOPT_TIMEOUT, 30);</p><p>// 尝试取得文件内容<p>$store = curl_exec ($ch);</p><p>// 检查文件是否正确取得<p>if (curl_errno($ch)){<p>echo “无法取得 URL 数据”;<p>//echo curl_error($ch);/*显示错误信息*/<p>exit;<p>}</p><p>// 关闭 CURL<p>curl_close($ch);</p><p>// 解析 HTML 的 区段<p>preg_match(“/(.*)/smUi”,$store, $htmlHeaders);<p>if(!count($htmlHeaders)){<p>echo “无法解析数据中的 区段”;<p>exit;<p>}</p><p>// 取得 中 meta 设置的编码格式<p>if(preg_match(“/]*http-equiv[^>]*charset=(.*)(\”|’)/Ui”,$htmlHeaders[1], $results)){<p>$charset = $results[1];<p>}else{<p>$charset = “None”;<p>}</p><p>// 取得</p><p><title>中的文字<p>if(preg_match(“/<title>(.*)/Ui”,$htmlHeaders[1], $htmlTitles)){<p>if(!count($htmlTitles)){<p>echo “无法解析<title>的内容”;<p>exit;<p>}<p>// 将</p><p><title>的文字编码格式转成 UTF-8<p>if($charset == “None”){<p>$title=$htmlTitles[1];<p>}else{<p>$title=iconv($charset, “UTF-8”, $htmlTitles[1]);<p>}<p>echo $title;<p>}</p><p></p></p> </div> <div class="keywords"> </div> <div class="tips">本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。</div> </div> <script>news_one();</script> <dl class="plbox" id="comments"> <dt>网友评论</dt> <dd> <textarea class="plcc">文明上网理性发言</textarea> <button class="sendpl">发表评论</button> <div class="pl_tips">网友评论仅供其表达个人看法,并不表明网站立场。</div> <div class="b10"></div> <ol class="pllist"> </ol> </dd> </dl> <script> $(".plcc").focus(function(){ if($('.plcc').val()=='文明上网理性发言') $('.plcc').val(''); }); $(".sendpl").click(function(){ var plcc=$('.plcc').val(),plcs=$('<p>'+plcc+'</p>').text(); if(plcs!='' && plcs!='文明上网理性发言'){ $('.pllist').prepend('<li><img src="https://900zi.500zi.com/statics/images/member/avatar.jpg" /><span class="adtime">2024-07-05 05:47</span><span class="plname">匿名59459178</span><span class="ipadd">[网友]<i>0.0.0.0</i></span><div class="pldata">'+plcs+' <font color="gray">(审核中)</font></div><div class="support"><span class="s1">顶0</span><span class="s2">踩0</span></div><div class="clear"></div></li>'); $.post("https://900zi.500zi.com/comment.php",{"commentid":"content_1-67878791-1","title":"PHP%E4%B8%AD%E4%BD%BF%E7%94%A8CURL%E8%8E%B7%E5%8F%96%E9%A1%B5%E9%9D%A2title%E4%BE%8B%E5%AD%90+curltitle","content":plcs,"token":"a18bae870bf803bb3cf1729909e46dc1"}); } }); </script> <script>show(3);</script> <div class="list mt20"> <div class="listTit"><span></span>相关阅读</div> <dl> <dt><a href="https://900zi.500zi.com/art/14/617/rLlR9mKvNX.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/14/617/271907d7efa8ab5f2ad6b6cf49be4664.jpg" alt="php curl获取title标题乱码怎么办" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/art/14/617/rLlR9mKvNX.html" target="_blank">php curl获取title标题乱码怎么办</a></p> <p class="des"></p> <p class="key"> <span>2019-06-22</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/art/15/955/rNg71xM4N1.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/15/955/8368a509ede5994927900d0555fda481.jpg" alt="php curl加密获取数据 PHP利用Curl模拟登录并获取数据例子" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/art/15/955/rNg71xM4N1.html" target="_blank">php curl加密获取数据 PHP利用Curl模拟登录并获取数据例子</a></p> <p class="des"></p> <p class="key"> <span>2023-11-02</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/art/14/557/lpqb9YdWLo.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/14/557/1e12243c3f1f34ebaf5f4ae0e16e070c.jpg" alt="PHP中使用CURL伪造来路抓取页面或文件【PHP】" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/art/14/557/lpqb9YdWLo.html" target="_blank">PHP中使用CURL伪造来路抓取页面或文件【PHP】</a></p> <p class="des"></p> <p class="key"> <span>2020-12-30</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/art/14/589/lpqbMyXkLo.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/14/589/9954dc8b0fe01d2aa22fa7f9c6431dbf.jpg" alt="PHP中使用CURL请求页面 使用fiddler进行抓包" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/art/14/589/lpqbMyXkLo.html" target="_blank">PHP中使用CURL请求页面 使用fiddler进行抓包</a></p> <p class="des"></p> <p class="key"> <span>2021-01-23</span> <span></span> </p> </dd> </dl> </div> </div> <div class="sideRight"> <script>news_two();</script> <div class="rightNews mt20"> <div class="rightTit"><span></span>扩展阅读</div> <div class="rightNewsList"> <dl> <dt><a href="https://www.qwen.cn/html/202012/06/1585027.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/492.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/202012/06/1585027.html" target="_blank"><em>php</em><em>获取</em>指定目录下的所有文件信息</a></p> </dd> </dl> <dl> <dt><a href="https://www.qwen.cn/html/200901/31/1534404.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/154.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/200901/31/1534404.html" target="_blank">如何<em>使用</em>Web3 JS文件API 在<em>页面</em><em>中</em>进行转账</a></p> </dd> </dl> <dl> <dt><a href="https://www.qwen.cn/html/201310/18/1557386.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/283.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/201310/18/1557386.html" target="_blank">如何<em>使用</em>Web3 JS文件API 在<em>页面</em><em>中</em>进行转账</a></p> </dd> </dl> <dl> <dt><a href="https://www.qwen.cn/html/201312/25/1534399.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/317.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/201312/25/1534399.html" target="_blank">如何用<em>PHP</em>读取excel文件内容 <em>获取</em>单元格数据</a></p> </dd> </dl> <dl> <dt><a href="https://www.qwen.cn/html/201611/10/1557539.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/9.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/201611/10/1557539.html" target="_blank">如何用<em>PHP</em>读取excel文件内容 <em>获取</em>单元格数据</a></p> </dd> </dl> <dl> <dt><a href="https://www.qwen.cn/html/201801/25/1468941.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/pic/395.jpg" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://www.qwen.cn/html/201801/25/1468941.html" target="_blank">3分钟短文|<em>PHP</em><em>获取</em>函数的代码片段 唯有反射最高效!</a></p> </dd> </dl> </div> </div> <div class="rightNews mt20"> <div class="rightTit"><span></span>最近发布</div> <div class="rightNewsList"> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/4onDeQkNm0.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/ea3f033dc0a93863ec3bfacb654f201d.jpg" alt="妈妈你真棒作文 900字" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/4onDeQkNm0.html" target="_blank">妈妈你真棒作文 900字</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/xXLXo7Qpre.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/59f0576a8a5e73d817c7022be0b592d6.jpg" alt="有关春节的作文900字3篇" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/xXLXo7Qpre.html" target="_blank">有关春节的作文900字3篇</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/14L1jMznaG.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/ec374618e092b756c638415c02188be7.jpg" alt="季节好段好句:在深秋时节900字" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/14L1jMznaG.html" target="_blank">季节好段好句:在深秋时节900字</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/abpABErLrM.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/f8ca2e9d9021c8b1b6d5b47b7d9e6d8b.jpg" alt="秋风吹拂下的淡云寄思念——900字作文素材大全" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/abpABErLrM.html" target="_blank">秋风吹拂下的淡云寄思念——900字作文素材大全</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/o17err00zk.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/eafa319a0fd72c7526b196237193d5af.jpg" alt="端午节的传统与习俗:亲情团圆与龙舟竞渡" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/o17err00zk.html" target="_blank">端午节的传统与习俗:亲情团圆与龙舟竞渡</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> <dl> <dt><a href="https://900zi.500zi.com/html/2024/0704/grLl9k7nXE.html" target="_blank"><img src="https://900zi.500zi.com/uploadfile/img/2024/07/04/d6ef797ab77f450c102c0bc5a9a5e773.jpg" alt="背影仿写作文 900字" width="230" height="150" /></a></dt> <dd> <p class="tit"><a href="https://900zi.500zi.com/html/2024/0704/grLl9k7nXE.html" target="_blank">背影仿写作文 900字</a></p> <p class="key"> <span>2024-07-04</span> <span></span> </p> </dd> </dl> </div> </div> <div class="rightClass mt20"> <div class="rightTit"><span></span>推荐专题</div> <div class="txt"> <a href="https://900zi.500zi.com/zhuanti/1/0/zjsw900z.html" title="这就是我900字">这就是我900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/zwdq900z.html" title="作文大全900字">作文大全900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/rtsqs900z.html" title="入团申请书900字">入团申请书900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/900zyjg.html" title="900字演讲稿">900字演讲稿</a> <a href="https://900zi.500zi.com/zhuanti/1/0/lswxdns900z.html" title="老师我想对你说900字">老师我想对你说900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/xsdzw900z.html" title="写事的作文900字">写事的作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/mmwxdns900z.html" title="妈妈我想对你说900字">妈妈我想对你说900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/yxzw900z.html" title="优秀作文900字">优秀作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/sjshzw900z.html" title="暑假生活作文900字">暑假生活作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/mazw900z.html" title="母爱作文900字">母爱作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/900zzwdq.html" title="900字作文大全">900字作文大全</a> <a href="https://900zi.500zi.com/zhuanti/1/0/wdlszw900z.html" title="我的老师作文900字">我的老师作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/dhg900z.html" title="读后感900字">读后感900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/900z.html" title="900字">900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/wdls900zzw.html" title="我的老师900字作文">我的老师900字作文</a> </div> </div> </div> </div> <script>show(4);</script> <div class="footer"> <div class="footLinks"> <div class="footLink"> <div class="tit">猜你喜欢:</div> <div class="txt txtTwo"> <a href="https://900zi.500zi.com/zhuanti/1/0/wdgszw900z.html" title="我的故事作文900字">我的故事作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/gzzw900z.html" title="高中作文900字">高中作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/thzw900z.html" title="童话作文900字">童话作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/zkmfzw900z.html" title="中考满分作文900字">中考满分作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/wdsjsh900z.html" title="我的暑假生活900字">我的暑假生活900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/zc900z.html" title="摘抄900字">摘抄900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/cyzw900z.html" title="春游作文900字">春游作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/900zzwdq.html" title="900字作文大全">900字作文大全</a> <a href="https://900zi.500zi.com/zhuanti/1/0/yjnwdszw900z.html" title="一件难忘的事作文900字">一件难忘的事作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/zwdq900zzy.html" title="作文大全900字左右">作文大全900字左右</a> <a href="https://900zi.500zi.com/zhuanti/1/0/yjg900z.html" title="演讲稿900字">演讲稿900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/lryhdhg900z.html" title="老人与海读后感900字">老人与海读后感900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/gqjzw900z.html" title="国庆节作文900字">国庆节作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/xsdzw900z.html" title="写事的作文900字">写事的作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/xrzw900z.html" title="写人作文900字">写人作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/cchm900zxszw.html" title="成长回眸900字叙事作文">成长回眸900字叙事作文</a> <a href="https://900zi.500zi.com/zhuanti/1/0/jjsqdzw900z.html" title="借景抒情的作文900字">借景抒情的作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/mazw900z.html" title="母爱作文900字">母爱作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/qqzw900z.html" title="亲情作文900字">亲情作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/xjzw900z.html" title="写景作文900字">写景作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/cczw900z.html" title="成长作文900字">成长作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/dhg900zzy.html" title="读后感900字左右">读后感900字左右</a> <a href="https://900zi.500zi.com/zhuanti/1/0/tnqs900z.html" title="童年趣事900字">童年趣事900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/xjsw900z.html" title="写景散文900字">写景散文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/ylw900z.html" title="议论文900字">议论文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/sb900z.html" title="随笔900字">随笔900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/900zgw.html" title="900字古文">900字古文</a> <a href="https://900zi.500zi.com/zhuanti/1/0/gddzw900z.html" title="感动的作文900字">感动的作文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/mw900z.html" title="美文900字">美文900字</a> <a href="https://900zi.500zi.com/zhuanti/1/0/tnqszw900z.html" title="童年趣事作文900字">童年趣事作文900字</a> </div> <div class="more">展开</div> </div> </div> <div class="copyRight pc"> <p class="left">900字范文 免责声明<span></span>© 2024 All Rights Reserved.</p> <p class="right"><a href="http://beian.miit.gov.cn/" target="_blank" rel="external nofollow">湘ICP备2024057051号</a><span></span><a href="/sitemap.html" target="_blank">网站地图</a><span></span><a href="/sitemap.xml" target="_blank">XML</a><span></span></p> </div> <div class="copyRight mobile"> <p>© 2024 All Rights Reserved.</p> <p><a href="/">900字范文</a> 免责声明<span></span></p> </div> </div> <div id="backTop" class="none"></div> <script type="text/javascript">op('content',67878791,1);</script> </body> </html>