Home Backend Development PHP Tutorial 兑现蜘蛛捕捉的PHP代码

兑现蜘蛛捕捉的PHP代码

Jun 13, 2016 am 10:54 AM
false return seo strpos

实现蜘蛛捕捉的PHP代码

SEO(Search Engine Optimization),汉译为搜索引擎优化,为近年来较为流行的网络营销方式,主要目的是增加特定关键字的曝光率以增加网站的能见度,进而增加销售的机会。分为站外SEO和站内SEO两种。SEO的主要工作是通过了解各类搜索引擎如何抓取互联网页面、如何进行索引以及如何确定其对某一特定关键词的搜索结果排名等技术,来对网页进行相关的优化,使其提高搜索引擎排名,从而提高网站访问量,最终提升网站的销售能力或宣传能力的技术。

?

很多做seo的, 经常会问为什么我的页面没有被收录,为什么我的快照还是上个星期的,怎么百度还不更新我的站点。这些都是刚入门问的问题。做seo的人都知道,知道搜索引擎的规律很重要。你要知道蜘蛛是否来过你的站点,什么时候来 过,是哪家蜘蛛。这些都有利于你针对性的做优化。

很多服务器支持蜘蛛爬行日志,但是大部分站长都是虚拟机,有的空间并不支持记录蜘蛛爬行。这时候就需要我们编写代码来记录蜘蛛的活动规律。

在网上找了很多的代码都不能正确使用,或者功能不完善。

只要自己研究起来。总结出一下一套代码,百分百保证使用。

<?phpfunction get_naps_bot(){$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);if (strpos($useragent, ‘googlebot’) !== false){return ‘Googlebot’;}if (strpos($useragent, ‘msnbot’) !== false){return ‘MSNbot’;}if (strpos($useragent, ’slurp’) !== false){return ‘Yahoobot’;}if (strpos($useragent, ‘baiduspider’) !== false){return ‘Baiduspider’;}if (strpos($useragent, ’sohu-search’) !== false){return ‘Sohubot’;}if (strpos($useragent, ‘lycos’) !== false){return ‘Lycos’;}if (strpos($useragent, ‘robozilla’) !== false){return ‘Robozilla’;}return false;}function nowtime(){$date=date(“Y-m-d.G:i:s”);return $date;}$searchbot = get_naps_bot();if ($searchbot) {$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);$url=$_SERVER['HTTP_REFERER'];$file=”robotslogs.txt”;$time=nowtime();$data=fopen($file,”a”);$PR=”$_SERVER[REQUEST_URI]“;fwrite($data,”Time:$time robot:$searchbot URL:$tlc_thispage\n page:$PR\r\n”);fclose($data);}?>
Copy after login

以上代码比网上流传的版本多了个记录搜索引擎请求页面记录,可以看到蜘蛛每次来爬取的是那个页面。更加利于分析蜘蛛对网站的权重以及对不同栏目和页 面的青睐。

Seo最终的是从实际出发,用数据说话,而不是凭空想象。一切优化的基础都是数据,一切优化的目的也是为了得到数据。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue3+TS+Vite development skills: how to optimize SEO Vue3+TS+Vite development skills: how to optimize SEO Sep 10, 2023 pm 07:33 PM

Vue3+TS+Vite development skills: How to perform SEO optimization SEO (SearchEngineOptimization) refers to optimizing the structure, content and keywords of the website to rank it higher in search engines, thereby increasing the website's traffic and exposure. . In the development of modern front-end technologies such as Vue3+TS+Vite, how to optimize SEO is a very important issue. This article will introduce some Vue3+TS+Vite development techniques and methods to help

Detailed explanation of the usage of return in C language Detailed explanation of the usage of return in C language Oct 07, 2023 am 10:58 AM

The usage of return in C language is: 1. For functions whose return value type is void, you can use the return statement to end the execution of the function early; 2. For functions whose return value type is not void, the function of the return statement is to end the execution of the function. The result is returned to the caller; 3. End the execution of the function early. Inside the function, we can use the return statement to end the execution of the function early, even if the function does not return a value.

What is the execution order of return and finally statements in Java? What is the execution order of return and finally statements in Java? Apr 25, 2023 pm 07:55 PM

Source code: publicclassReturnFinallyDemo{publicstaticvoidmain(String[]args){System.out.println(case1());}publicstaticintcase1(){intx;try{x=1;returnx;}finally{x=3;}}}#Output The output of the above code can simply conclude: return is executed before finally. Let's take a look at what happens at the bytecode level. The following intercepts part of the bytecode of the case1 method, and compares the source code to annotate the meaning of each instruction in

What is a 301/302 redirect? How to redirect the website? What is a 301/302 redirect? How to redirect the website? Jul 12, 2022 pm 12:07 PM

What is a 301/302 redirect? How to redirect the website? This article will take you through 301/302 jumps, introduce the jump methods, and analyze them from the SEO perspective to see which method is practical. I hope it will be helpful to everyone!

SSR technology application practice in Vue 3 to improve the SEO effect of the application SSR technology application practice in Vue 3 to improve the SEO effect of the application Sep 08, 2023 pm 12:15 PM

SSR technology application practice in Vue3 to improve the SEO effect of applications. With the rapid development of front-end development, SPA (Single Page Application) has become mainstream. The benefits of SPA are self-evident and can provide a smooth user experience, but there are some challenges in terms of SEO (search engine optimization). Since SPA only returns an HTML template in the front-end rendering stage, most of the content is dynamically loaded through JavaScript, causing search engines to have difficulties in crawling, indexing, and ranking. To solve this problem,

How Vue performs SEO optimization and practical suggestions How Vue performs SEO optimization and practical suggestions Jun 09, 2023 pm 04:13 PM

With the continuous development of web technology, more and more websites are beginning to use Vue as the front-end framework. Although Vue can provide a good user experience and development efficiency, there are still some challenges in search engine optimization. This article will introduce how Vue performs SEO optimization and some practical suggestions. 1. Vue’s SEO issues Vue’s SEO issues mainly include the following points: Server-side rendering issues: Vue is a single-page application (SPA), which means that it is rendered in the browser through JavaScript

Summary of Vue development experience: Practice in solving SEO and search engine optimization Summary of Vue development experience: Practice in solving SEO and search engine optimization Nov 22, 2023 am 08:44 AM

Summary of Vue development experience: Practice in solving SEO and search engine optimization In the current era of rapid development of mobile Internet and Web technology, search engines are still one of the most important ways to obtain information on the Internet. For websites that need to gain high exposure in search engines, SEO (SearchEngineOptimization) is an essential task. So, for web development projects using Vue technology, how to achieve SEO and search engine optimization? Vue

What is the difference between SEO and SEM What is the difference between SEO and SEM Aug 10, 2023 pm 03:48 PM

The difference between SEO and SEM is 1. SEO refers to search engine optimization, while SEM refers to search engine marketing; 2. SEO optimizes the visibility of the website so that it naturally ranks in front of organic search results, while SEM uses advertising to Paid ranking at the top of search results; 3. SEO is a long-term strategy, which requires continuous and sustained efforts to maintain the website's ranking in search engines, while SEM can be flexibly adjusted and implemented, and it can quickly adjust the advertising strategy as needed. and budget.

See all articles