Home Backend Development PHP Tutorial PHP implementation to obtain Baidu inclusion and snapshot code_PHP tutorial

PHP implementation to obtain Baidu inclusion and snapshot code_PHP tutorial

Jul 13, 2016 pm 04:55 PM
php and code use accomplish Snapshot included article Baidu of Obtain

This article introduces the use of PHP to obtain Baidu's snapshots and included codes. Let's take a look at what kind of functions and encoding conversion functions are used in PHP in this example.

Let’s take a look at the effect code as follows

PHP implementation to obtain Baidu inclusion and snapshot code_PHP tutorial

The code is as follows
 代码如下 复制代码

    $domain = "www.hzhuti.com";  /*欲查询的域名*/
    $site_url = 'http://www.baidu.com/s?wd=site%3A';
    $all = $site_url.$domain; /*域名所有收录的网址*/
    $today = $all.'&lm=1';    /*域名今日收录的网址*/
    $utf_pattern = "/找到相关结果数(.*)个/";
    $gb2312_pattern = iconv("UTF-8","GB2312",$utf_pattern); /*因为百度为GB2312编码*/
    $kz_pattern = "/(.*)/"; /*用以匹配快照日期的字符串*/
    $times = "/d{4}-d{1,2}-d{1,2}/"; /*匹配快照日期的正则表达式,如:2011-8-4*/
    $s0 = @file_get_contents($all);    /*将site:www.hzhuti.com的网页置入$s0字符串中*/
    $s1 = @file_get_contents($today);
    preg_match($gb2312_pattern,$s0,$all_num); /*匹配"找到相关结果数*个"*/
    preg_match($gb2312_pattern,$s1,$today_num);
    preg_match($kz_pattern,$s0,$temp);
    preg_match($times,$temp[0],$screenshot);
    if($all_num[1] == "")
        $all_num[1] = 0;
    if($today_num[1] == "")
        $today_num[1] = 0;
    if($screenshot[0] == "")
        $screenshot[0] = "暂无快照";
?>

   


    Test
   

   

百度收录:


   

百度今日收录:


   

百度快照日期:



Copy code
$domain = "www.hzhuti.com"; /*Domain name to be queried*/
$site_url = 'http://www.baidu.com/s?wd=site%3A';
$all = $site_url.$domain; /*All URLs included in the domain name*/
$today = $all.'&lm=1'; /*The URL of the domain name included today*/
$utf_pattern = "/Number of related results found (.*)/";
$gb2312_pattern = iconv("UTF-8","GB2312",$utf_pattern); /*Because Baidu encodes GB2312*/
$kz_pattern = "/(.*)/"; /*String used to match snapshot date*/
$times = "/d{4}-d{1,2}-d{1,2}/"; /*Regular expression matching snapshot date, such as: 2011-8-4*/
$s0 = @file_get_contents($all); /*Place the web page of site:www.hzhuti.com into the $s0 string*/
$s1 = @file_get_contents($today);
Preg_match($gb2312_pattern,$s0,$all_num); /*Match "*number of relevant results found"*/
Preg_match($gb2312_pattern,$s1,$today_num);
Preg_match($kz_pattern,$s0,$temp);
Preg_match($times,$temp[0],$screenshot);
If($all_num[1] == "")
          $all_num[1] = 0;
If($today_num[1] == "")
         $today_num[1] = 0;
If($screenshot[0] == "")
         $screenshot[0] = "No snapshot yet";
?>


Test


Baidu included:> ;


Baidu included today: a>


Baidu snapshot date: p>

http://www.bkjia.com/PHPjc/631643.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/631643.html
TechArticle
This article introduces the use of php to obtain baidu's snapshot and inclusion code. Let's take a look at what to use in php Such a function and the application of the encoding conversion function in this example. Let’s take a look first...
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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 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)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Quick Guide CakePHP Quick Guide Sep 10, 2024 pm 05:27 PM

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

ai tool recommendation ai tool recommendation Nov 29, 2024 am 11:08 AM

This article introduces six popular AI tools, including Douyin Doubao, Wenxin Yige, Tencent Zhiying, Baidu Feipiao EasyDL, Baidu AI Studio and iFlytek Spark Cognitive Large Model. These tools cover different functions such as text creation, image generation, video editing, and AI model development. Choosing the right AI tool requires consideration of factors such as functional requirements, technical level, and cost budget. These tools provide convenient and efficient solutions for individuals and businesses in need of AI assistance.

See all articles