PHP is a simple way to get the indexing amount of Baidu search and sogou search for websites. php Baidu search

Source: Internet
Author: User
Tags ereg

PHP is a simple way to get the indexing amount of Baidu search and sogou search for websites. php Baidu search

This example describes how PHP can retrieve the indexing volume of Baidu search and sogou search on a website. We will share this with you for your reference. The details are as follows:

Get the indexing code of Baidu search and sogou search on the website. It can be used to obtain the indexing quantity of the website domain name in the search engine. I have been searching for this API but cannot find it, I found an example on the Internet and learned to modify it. I can get the indexing amount of Baidu search and sogou search normally. The principle is to get the number of search engine site: domain results, then, capture the quantity and display it.

 

Function baidu ($ url) {$ baidu = "http://www.baidu.com/s? Wd = site :". $ url; $ site = file_get_contents ($ baidu); ereg ("This website has a total (. *) webpage indexed by Baidu ", $ site, $ count); $ count = str_replace (" This website has a total of "," ", $ count ); $ count = str_replace ("Baidu indexed webpages", "", $ count); $ count = str_replace (",", "", $ count ); $ count = str_replace ("", "", $ count); return strip_tags ($ count [0]);} function sogou ($ url) {$ sogou = "http://www.sogou.com/web? Query = site :". $ url; $ site = file_get_contents ($ sogou); ereg ("locate approx (. *) result ", $ site, $ count); $ count = str_replace (" locate approx "," ", $ count); $ count = str_replace (" result ", "", $ count); $ count = str_replace (",", "", $ count); $ count = str_replace ("", "", $ count ); return strip_tags ($ count [0]) ;}?> Www.jb51.net Baidu <? Php echo baidu ('www .jb51.net');?> <Br> www.jb51.net sogou entries <? Php echo sogou ('www .jb51.net');?> Entries

Shows the running effect:

Note:The file encoding must be in UTF-8 format.

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.