Use curl in php to check if the page is indexed by Baidu _ PHP Tutorial

Source: Internet
Author: User
Php uses curl to check whether the page is indexed by Baidu. To sort out the website recently, you need to check which pages on the website are not indexed by Baidu search engine for relevant adjustments. Because the use of the site command lines is really not recently to sort out the website, you need to check which pages on the website are not indexed by Baidu search engine for relevant adjustments. Since the use of the site command lines is really not good, I thought of using the php program for batch processing, research, found that it is actually very simple, the following describes whether the detection page implemented by the author using php has been indexed by Baidu.

The code below is as follows:

The code is as follows:


/*
* Checks if the webpage is indexed by Baidu. if the returned value is 1, the system returns 0, indicating that the webpage is not indexed.
* @ Param string $ url the url to be detected
*/
Function checkBaiduInclude ($ url ){
$ Url = 'http: // www.baidu.com/s? Wd = '. $ url;
$ Curl = curl_init ();
Curl_setopt ($ curl, CURLOPT_URL, $ url );
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
$ Rs = curl_exec ($ curl );
Curl_close ($ curl );
If (! Strpos ($ rs, 'Sorry, not found ')){
Return 1;
} Else {
Return 0;
}
}

The meaning is very simple, for example, the need to detect the http://www.phpernote.com/javascript-function/833.html URL is indexed, you only need:

CheckBaiduInclude ('http: // www.phpernote.com/javascript-function/833.html'); check the result by yourself.

This article is reproduced from: PHP programmer notes

Bytes. Because I can't see it by using the site command...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.