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.