Php baidu indexing query program

Source: Internet
Author: User
The code is as follows: Copy code

*/
Header ('content-type: text/html; charset = utf-8 ');
Require ('function. Php ');

$ Url = strtolower (trim ($ _ get ['URL']);
$ Lm = intval ($ _ get ['LM ']);
$ Pn = intval ($ _ get ['pn ']);

$ Url = getshorturl ($ url );

If (empty ($ pn) $ pn = 1;

Switch ($ lm ){
Case 1:
$ Timestr = '24 hrs ';
Break;
Case 7:
$ Timestr = 'One week ';
Break;
Case 30:
$ Timestr = 'one month ';
Break;
Case 360:
$ Timestr = 'year ';
Break;
Default:
$ Timestr = 'All Time ';
Break;
}
?>
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<? Php
If (empty ($ url )){
?>
<Title> 35dir Baidu recently indexed query-35 category directories </title>
<Meta name = "keywords" content = "Baidu recently indexed query"/>
<Meta name = "description" content = "Baidu's recent indexed queries can be queried based on the specified time range (last 24 hours, one week, one month, one year, and all time, this allows you to know the website's indexing status in a certain period of time. "/>
<? Php
} Else {
?>
<Title> <? Php echo $ url;?> Baidu recently <? Php echo $ timestr;?> Details-35 category directories </title>
<Meta name = "keywords" content = "<? Php echo $ url;?>, Baidu recently indexed query "/>
<Meta name = "description" content = "<? Php echo $ url;?>, Baidu recently <? Php echo $ timestr;?> Include query results. "/>
<? Php
}
?>
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<Meta name = "copyright" content = "powered by 111cn.net"/>
<Meta http-equiv = "pragma" content = "no-cache"/>
<Script type = "text/webpage effects" src = "jquery. js"> </script>
<Script type = "text/jscript">
Function checkfrm (){
If ($ ("# url"). attr ("value") = ""){
Alert ("Enter the domain name to query! ");
$ ("# Url"). focus ();
Return false;
} Else {
Var reexp =/^ ([a-z0-9-] {1 ,}.)? [A-z0-9-] {2,}. ([a-z0-9-] {1 ,}.)? [A-z0-9] {2,} $/I;
If (! Reexp. test ($ ("# url"). attr ("value "))){
Alert ("Enter the correct domain name! ");
$ ("# Url"). focus ();
Return false;
  }
 }
Return true;
}
</Script>
<Link href = "skin/style.css tutorial" rel = "stylesheet" type = "text/css"/>
</Head>

<Body>
<Div id = "topbar"> website navigation: <a href = "http://www.111cn.net/" target = "_ blank"> 35 category directories </a> | <a href = "http://www.opdir.cn/" target = "_ blank"> open directory </a> </div>
<Div id = "container">
<Div id = "header">
<A class = "logo" href = "http://tool.111cn.net/baidu/" title = "35dir Baidu recently indexed query"> </a>
<Div id = "search">
<Form name = "myso" method = "get" action = "" onsubmit = "return checkfrm ();">
<Span style = "font: bold 16px normal;"> http: // </span> <input name = "url" id = "url" type = "text" size = "50" class = "sipt" value = "<? Php echo $ url;?> "/>
<Input type = "hidden" name = "lm" value = "1"/>
<Input type = "submit" class = "sbtn" value = ""/>
<Div class = "tips tutorial"> Example: <a href = "javascript: void (0);" onclick = "$ ('# URL '). attr ('value', '111cn. net ') "> 111cn.net </a>, <a href =" javascript: void (0); "onclick =" $ (' # URL '). attr ('value', 'www .111cn.net ') "> www.111cn.net </a>. The query results with" www "and without" www "are different </div>
</Form>
</Div>
</Div>
<? Php
If (! Empty ($ url )){
?>
<Div class = "tool"> <strong> query by time period: </strong> <a href = ""> Last 24 Hours </a> <a href = ""> last week </a> <a href = ""> Recent </a> <a href = ""> Total number of records in the last year </a> <a href = ""> </a> </div>
<Div id = "mainer">
<? Php
$ Query_url = 'http: // www.baidu.com/s? Wd = site % 3a '. $ url.' & pn = '. $ pn.' & lm = '. $ lm;
$ Line_arr = @ file ($ query_url );
   
$ Content = implode ('###', $ line_arr );
$ Content = @ mb_convert_encoding ($ content, 'utf-8', 'gb2312 ');
  
// Index
If (preg_match ('/find the relevant webpage (.*?) Articles/I ', $ content, $ index )){
$ Baiduindex = str_replace ('approx. ', '', $ index [1]);
} Else {
$ Baiduindex = '-';
  }
?>
<Div class = "content">
<H2> Baidu recently <font color = "# ff6600"> <? Php echo $ timestr;?> </Font> a total of websites (<a href = "<? Php echo getfullurl ($ url);?> "Target =" _ blank "> <? Php echo $ url;?> </A>) <font color = "# ff6600"> <? Php echo $ baiduindex;?> </Font> pages <Div>
<? Php
$ Content = strstr ($ content, '<table cellpadding = "0" cellspacing = "0" class = "result "');
$ End = strpos ($ content, '<div id = "search"> ');
$ Content = substr ($ content, 0, $ end );
   
$ Item_arr = explode ('<tr> <td class = f>', $ content );
 
// Showpage
If (preg_match ('/<p id = "page"> (.*?) </Div>/', $ content, $ page_arr )){
$ Showpage = str_replace ('s? Wd = site % 3a ','? Url = ', $ page_arr [1]);
$ Showpage = str_replace ('[', '', $ showpage );
$ Showpage = str_replace (']', '', $ showpage );
   }
 
$ I = 0;
$ Strhtml = '<ul class = "sitelist"> ';
Foreach ($ item_arr as $ item ){
If (preg_match ('/<a onmousedown = "(.*?) "Href = "(.*?) "Target =" _ blank "> <font size =" 3 "> (.*?) </Font> </a> <br> <font size =-1> (.*?) <Font color = "#008000"> (.*?) </Font>-<a href = "(.*?) "Target =" _ blank "class =" m ">/I ', $ item, $ siteinfo )){
$ Sitename = $ siteinfo [3];
$ Siteurl = $ siteinfo [2];
$ Sitedesc = $ siteinfo [4];
$ Siteltime = $ siteinfo [5];
$ Sitecache = $ siteinfo [6];
     
$ Strhtml. = '<li> ';
$ Strhtml. = '<strong> <em> '. $ I. '. </em> <a href = "'. $ siteurl. '"target =" _ blank "> '. $ sitename. '</a> </strong> ';
$ Strhtml. = '<p>'. $ sitedesc. '</p> ';
$ Strhtml. = '<address> '. $ siteltime. '-<a href = "'. $ sitecache. '"target =" _ blank "> Baidu snapshot </a> </address> ';
$ Strhtml. = '</li> ';
    }
$ I ++;
   }
$ Strhtml. = '</ul> ';
$ Strhtml. = '<div class = "showpage">'. $ showpage. '</div> ';
 
Echo $ strhtml;
?>
</Div>
</Div>
</Div>
<? Php
    }
?>
  
</Div>
</Body>
</Html>

Function file

<? Php
Function getfullurl ($ url ){
If ($ url! = ""){
$ Url_parts = parse_url ($ url );
If ($ url_parts ['scheme '] = ""){
$ Url = "http: //". $ url;
  }
 }
Return $ url;
}
 
Function getaskurl ($ url ){
If ($ url! = ""){
$ Url_parts = parse_url ($ url );
If ($ url_parts ['host'] = ""){
$ Url = $ url_parts ['path'];
} Else {
$ Url = $ url_parts ['host'];
        }
 }
Return $ url;
}
 
Function format_number ($ number ){
If ($ number = '') return "-";
$ Nlen = strlen ($ number );
While ($ nlen> 3 ){
$ Fnumber = ",". substr ($ number, $ nlen-3, 3). $ fnumber;
$ Number = substr ($ number, 0,-3 );
$ Nlen = strlen ($ number );
 }
  
If ($ nlen <= 3 ){
$ Fnumber = $ number. $ fnumber;
 }
Return $ fnumber;
}
?>

Source code download address

Http://down.111cn.net/s/2010/1025/21415.html

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.