[不花钱站长]:从免费域名开始[0元] Oracle永久免费VPS[0元] VPS环境搭建免费脚本[0元] 秒变大盘挂载免费网盘[0元] 小白免费采集器1天500W[0元] CF免费DNS+CDN服务[0元]
[零基础网赚]:撸本站免费源码[0元] 网站强引免费蜘蛛法[0元] 图片视频文件免费存储[0元] 外链轻松发布免费友链[0元] 入坑免费教程学习源代码[0元] 网上百种+赚钱联盟推荐[?元]

↑↑主机测评网牛逼个人站长零成本从白嫖到精通指南↑↑


给WordPress博客添加一个搜索引擎蜘蛛爬行及分析页面

全球[VPS测评]来源:主机测评网2023-01-28点击:673
【性价之王】【线路之王】【价格之王】【配置之王】
【免费之王】【香港首推】【梯子之王】【独服之王】
给WordPress博客添加一个搜索引擎蜘蛛爬行及分析页面

在新站或网站收录有问题时,想要了解搜索引擎蜘蛛对我们WordPress博客的爬行情况,对网站进行针对性的SEO优化。

每次打开服务器端访问日志查看非常麻烦,那么建立一个蜘蛛爬行及分析页面还是很有必要的。

网上已经有很多分享 WordPress 如何建立蜘蛛爬行及分享的页面文章了,不过大部分都是一个 txt 页面,密密麻麻一大堆字符,根本就看不出来哪个是哪个,所以根据网上大神分享的代码稍稍优化后让蜘蛛爬行结果更加直观明白。

内容 1 具体效果如下: 2 WordPress WordPress博客添加蜘蛛爬行及分享页面步骤 2.1 相关文章

具体效果如下:

WordPress WordPress博客添加蜘蛛爬行及分享页面步骤

1、将以下代码添加当前主题的 functions.php 文件中(或添加到一个 PHP 文件中,然后在 functions.php 文件中引入该文件即可)。

//自动分析蜘蛛,tzw520.cnmake_log_file();function make_log_file(){//log 文件名$filename = 'mylogs.txt';//去除 rc-ajax 评论以及 cron 机制访问记录if(strstr($_SERVER["REQUEST_URI"],"rc-ajax")== false&& strstr($_SERVER["REQUEST_URI"],"wp-cron.php")== false ) {$word .= date('mdHis',$_SERVER['REQUEST_TIME'] + 3600*8) . " ";//访问页面$word .= $_SERVER["REQUEST_URI"] ." ";//协议$word .= $_SERVER['SERVER_PROTOCOL'] ." ";//方法,POST OR GET$word .= $_SERVER['REQUEST_METHOD'] . " ";//$word .= $_SERVER['HTTP_ACCEPT'] . " ";//获得浏览器信息$word .= getbrowser(). " ";//传递参数$word .= "[". $_SERVER['QUERY_STRING'] . "] ";//跳转地址$word .= $_SERVER['HTTP_REFERER'] . " ";//获取 IP$word .= getIP() . " ";$word .= "\n";$fh = fopen($filename, "a");fwrite($fh, $word);fclose($fh);}}//获取 IP 地址,网上现成代码 tzw520.cnfunction getIP() //get ip address{if (getenv('HTTP_CLIENT_IP')){$ip = getenv('HTTP_CLIENT_IP');}else if (getenv('HTTP_X_FORWARDED_FOR')){$ip = getenv('HTTP_X_FORWARDED_FOR');}else if (getenv('REMOTE_ADDR')){$ip = getenv('REMOTE_ADDR');}else{$ip = $_SERVER['REMOTE_ADDR'];}return $ip;}//获取浏览器信息,移动端,平板电脑数据还未加上。tzw520.cnfunction getbrowser(){$Agent = $_SERVER['HTTP_USER_AGENT'];$browser = '';$browserver = ''; if(ereg('Mozilla', $Agent) && ereg('Chrome', $Agent)){$temp = explode('(', $Agent);$Part = $temp[2];$temp = explode('/', $Part);$browserver = $temp[1];$temp = explode(' ', $browserver);$browserver = $temp[0];$browserver = $browserver;$browser = 'Chrome';}if(ereg('Mozilla', $Agent) && ereg('Fiox', $Agent)){$temp = explode('(', $Agent);$Part = $temp[1];$temp = explode('/', $Part);$browserver = $temp[2];$temp = explode(' ', $browserver);$browserver = $temp[0];$browserver = $browserver;$browser = 'Fiox';}if(ereg('Mozilla', $Agent) && ereg('Opera', $Agent)){$temp = explode('(', $Agent);$Part = $temp[1];$temp = explode(')', $Part);$browserver = $temp[1];$temp = explode(' ', $browserver);$browserver = $temp[2];$browserver = $browserver;$browser = 'Opera';}if(ereg('Mozilla', $Agent) && ereg('MSIE', $Agent)){$temp = explode('(', $Agent);$Part = $temp[1];$temp = explode(';', $Part);$Part = $temp[1];$temp = explode(' ', $Part);$browserver = $temp[2];$browserver = $browserver;$browser = 'Internet Explorer';}if($browser != ''){$browseinfo = $browser.' '.$browserver;}else{$browseinfo = $_SERVER['HTTP_USER_AGENT'];}return $browseinfo;} function get_spider_log($atts) {extract(shortcode_atts(array('text' => 'yes'),$atts));$fh = fopen(site_url() ."/mylogs.txt", "r");$contents = "";while(!feof($fh)){$contents .= fread($fh, 8080);}fclose($fh);$str = "";$showtime=date("md");if($text == "yes") {$str.= "<div style='background-color:#33A1C9;color:white;text-align:center;font-size:20px;height:50px;line-height:50px;'>以下为国内常用蜘蛛</div>";}$mytmp = array();//google$google = 0;if($text == "yes")$str.= '<li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;"> 谷歌蜘蛛</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Googlebot\/",$text);$google += $mytmp[0];$str.= $mytmp[1];$mytmp = show_spider_result($showtime,$contents,"Googlebot-Image\/",$text);$google += $mytmp[0];$str.= $mytmp[1];$mytmp = show_spider_result($showtime,$contents,"Googlebot-Mobile\/",$text);$google += $mytmp[0];$str.= $mytmp[1];$mytmp = show_spider_result($showtime,$contents,"Feedfetcher-Google",$text);$google += $mytmp[0];$str.= $mytmp[1]; // baidu$baidu = 0;if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">百度蜘蛛</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Baiduspider\/",$text);$baidu += $mytmp[0];$str.= $mytmp[1];$mytmp = show_spider_result($showtime,$contents,"Baiduspider-image",$text);$baidu += $mytmp[0];$str.= $mytmp[1]; //bing$bing = 0;if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">bingbot 蜘蛛</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"bingbot\/",$text);$bing += $mytmp[0];$str.= $mytmp[1];$mytmp = show_spider_result($showtime,$contents,"msnbot-media\/",$text);$bing += $mytmp[0];$str.= $mytmp[1]; //sogou$sogou = 0;if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">搜狗蜘蛛</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Sogou web spider\/",$text);$sogou += $mytmp[0];$str.= $mytmp[1]; //soso$soso = 0;if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">Soso 蜘蛛</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Sosospider\/",$text);$soso += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= "<div style='background-color:#FA8072;color:white;text-align:center;margin:auto;font-size:20px;height:50px;line-height:50px;'>以下为垃圾蜘蛛,可屏蔽抓取</div>";//jike$else = 0;if($text == "yes")$str.= '<li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">Jike Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"JikeSpider",$text);$else += $mytmp[0];$str.= $mytmp[1]; //easouif($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">Easou Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"EasouSpider",$text);$else += $mytmp[0];$str.= $mytmp[1]; //yisouif($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">YisouSpider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"YisouSpider",$text);$else += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">YandexBot Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"YandexBot\/",$text);$else += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">Mail.RU Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Mail.RU_Bot\/",$text);$else += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">AcoonBot Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"AcoonBot\/",$text);$else += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">Exabot Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"Exabot\/",$text);$else += $mytmp[0];$str.= $mytmp[1]; if($text == "yes")$str.= '<br><li style = "text-align:center;font-weight: bold;list-style:none;margin:20px;color:orangered;">spbot Spider</li><hr/> ';$mytmp = show_spider_result($showtime,$contents,"spbot\/",$text);$else += $mytmp[0];$str.= $mytmp[1]; $str.= draw_canvas($google,$baidu,$bing,$sogou,$soso,$else);return $str;}function show_spider_result($time,$contents,$str,$text){$count = array();$count[0] = preg_match_all("/".$time."\d*\s\/\S*\s.*".$str."/",$contents,$mymatches);if($text == "yes") {$str = preg_replace("{\\\/}","",$str);$count[1].= "<br><p style='text-align:center;'> 蜘蛛类型:".$str.": 爬行次数:".$count[0]."</p>";if($count[0] >0) {$tmp = substr($mymatches[0][$count[0]-1],4,6);$tmp = substr($tmp,0,2) .":" . substr($tmp,2,2) .":" .substr($tmp,4,2) ;$count[1].= " <p style='text-align:center;'> 最后爬行时间:'. $tmp.'</p>";}}return $count; } function draw_canvas($google,$baidu,$bing,$sogou,$soso,$else){$tmp = $google + $baidu + $bing + $sogou + $soso + $else;if($tmp == 0) {return "<br><br>数据不足,无法生成分析图。<br><br>";}$google2 = $google*100/$tmp;$baidu2 = $baidu*100/$tmp;$bing2 = $bing*100/$tmp;$sogou2 = $sogou*100/$tmp;$soso2 = $soso*100/$tmp;$else2 = $else*100/$tmp;$str.= "<br><div style='border-top: 1px solid #e6e6e6;'><br><div style='width:auto;border-width:1px;border-style:groove;padding:15px;text-align:center;list-style:none;'><b>蜘蛛爬行分析图:</b><br>";$str.= "日期:" . date("Y-m-d");$str.= "<br>蜘蛛一共爬行". $tmp . "次:<br>";$str.= "<li><span style='color:#33A1C9;'>google:". $google ."次(". intval($google2) ."%)</span></li>";$str.= "<li><span style='color:#0033ff;'>baidu:". $baidu ."次(". intval($baidu2) ."%)</span></li>";$str.= "<li><span style='color:#872657;'>bing:". $bing ."次(". intval($bing2) ."%)</span></li>";$str.= "<li><span style='color:#FF9912;'>sogou:". $sogou ."次(". intval($sogou2) ."%)</span></li>";$str.= "<li><span style='color:#FF6347;'>soso:". $soso ."次(". intval($soso2) ."%)</span></li>";$str.= "<li><span style='color:#55aa00;'>else:". $else ."次(". (100 - intval($google2) - intval($baidu2) - intval($bing2) - intval($sogou2) - intval($soso2)) ."%)</span></li></div>";//$str.= "<img src = 'http://chart.apis.google.com/chart?cht=p3&chco=33A1C9,0033ff,872657,FF9912,FF6347,55aa00&chd=t:".$google2 .",".$baidu2.",".$bing2.",".$sogou2.",".$soso2.",".$else2."&chs=400x200&chl=google|baidu|bing|sogou|soso|else' /></div><br>";//这里好像应该是生成一个图表,但不知道 api 好像失效了,天真找不到可以替代的,于是就给注释了return $str;}add_shortcode('spiderlogs','get_spider_log'); //自动分析蜘蛛结束

2、登录 WordPress 后台 >> 页面 >> 新建页面,页面名称随意即可,然后把以下代码直接放在内容中并发布页面即可。

[spiderlogs]

具体如下图所示:


[SEO]历史优惠活动内容
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • RCP.NET 日本VPS限量促销 三网联通CUG(10099) 1Gbps带宽2022-12-27
  • 网站SEO优化及UED究竟该怎么做,如何提高网站流量及用户体验!2022-12-25
  • WordPress SEO标题/关键字/描述优化插件 – WP SEO TDK介2022-12-25
  • WordPress SEO优化→如何为WordPress分页添加canonica2022-12-24
  • 百度云加速专业版限量五折‭795‬元/年(原价1590元),百度旗下专业CDN/2022-12-24
  • 蜗牛官方SEO平台→专业的SEO平台,全程自助添加SEO词语,价格便宜,效果好,2022-12-24
  • RackNerd美国独立服务器_SEO站群服务器32个C段IP地址/10G大带宽2022-12-25
  • 华纳云→香港CN2站群服务器上线,支持1C/2C/4C不同C段可选,多达253个2022-12-25
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-25
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-24
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-24
  • 华纳云:香港CN2站群服务器上线,支持1C/2C/4C不同C段可选,多达253个2022-12-24
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-24
  • 华纳云:香港CN2站群服务器上线,支持1C/2C/4C不同C段可选,多达253个2022-12-24
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-24
  • 华纳云:香港CN2站群服务器上线,支持1C/2C/4C不同C段可选,多达253个2022-12-24
  • 精词快排SEO不限指数任意关键词1元/天最快最快隔天上首页2022-12-24
  • 华纳云:香港CN2站群服务器上线,支持1C/2C/4C不同C段可选,多达253个2022-12-24
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • 站群部署运营教程,站群怎么做?怎么用站群做seo,提升网站权重?2022-12-23
  • racknerd美国洛杉矶大硬盘存储服务器、SEO站群服务器等多款独服促销,价格2022-12-23
  • uk2-商业云主机/3个免费域名/免费SSL/免费SEO工具/4.95英镑2022-12-20
  • uk2-商业云主机/3个免费域名/免费SSL/免费SEO工具/4.95英镑2022-12-20
  • turnkeyinternet-多IPSEO主机2.5折2022-12-20
  • #站群主机,SEO主机# hostexcellence-7.95美元/15个IP2022-12-20
  • raksmart→便宜香港站群服务器 cn2+bgp网络 SEO效果超好 速度爆2022-12-20
  • racknerd→洛杉矶(16C)SEO站群服务器、160T存储服务器 低至142022-12-19

  • 猜你可能想看的VPS


    转载请注明原文地址:http://www.motoll.com/read-224883.html

    使用该VPS服务器的演示站:

    下一篇       上一篇