Home Backend Development PHP Tutorial 获取关键字百度排名位数的方法,主要应该是正则表达式,该如何解决

获取关键字百度排名位数的方法,主要应该是正则表达式,该如何解决

Jun 13, 2016 pm 01:40 PM
cellpadding cellspacing class quot

获取关键字百度排名位数的方法,主要应该是正则表达式
例如从百度搜索csdn,
获取的结果部份如下:

HTML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
Copy after login


其中

中的 id="1" 的 1则是以csdn为关键字时,www.csdn.net的百度自然排名。在 "'})" href="http://www.csdn.net/"target="_blank">"这串字符前数第15个字符,也是他的排名数字 1
我现在只能file_get_contents获取到整个的搜索结果,如何“提炼”出这个 id="1" 的 1呢? 请各位指教,谢谢!

我的思路是,从"'})" href="http://www.csdn.net 这段代码向前搜索第15个字条,获取他,也可以。

请各位指教,谢谢!

------解决方案--------------------
2点了,居然没人回答,看样子都在昏迷了。

$Str='
}';
$Pat='/id="([0-9])+"/';
preg_match($Pat, $Str,$Marray);
echo $Marray[1];
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
How to use classes and methods in Python How to use classes and methods in Python Apr 21, 2023 pm 02:28 PM

Concepts and instances of classes and methods Class (Class): used to describe a collection of objects with the same properties and methods. It defines the properties and methods common to every object in the collection. Objects are instances of classes. Method: Function defined in the class. Class construction method __init__(): The class has a special method (construction method) named init(), which is automatically called when the class is instantiated. Instance variables: In the declaration of a class, attributes are represented by variables. Such variables are called instance variables. An instance variable is a variable modified with self. Instantiation: Create an instance of a class, a specific object of the class. Inheritance: that is, a derived class (derivedclass) inherits the base class (baseclass)

What does class mean in python? What does class mean in python? May 21, 2019 pm 05:10 PM

Class is a keyword in Python, used to define a class. The method of defining a class: add a space after class and then add the class name; class name rules: capitalize the first letter. If there are multiple words, use camel case naming, such as [class Dog()].

The difference between cellpadding and cellspacing The difference between cellpadding and cellspacing Nov 13, 2023 am 09:46 AM

The difference between cellpadding and cellspacing: 1. The cellpadding attribute is used to set the distance between the cell content and the cell border, while the cellspacing attribute is used to set the distance between adjacent cells; 2. The cellpadding can be the content within the cell. Providing a certain amount of blank space so that there is a certain gap between content and borders, and cellspacing controls the size of the blank space between adjacent cells to make the table look more tidy and so on.

Replace the class name of an element using jQuery Replace the class name of an element using jQuery Feb 24, 2024 pm 11:03 PM

jQuery is a classic JavaScript library that is widely used in web development. It simplifies operations such as handling events, manipulating DOM elements, and performing animations on web pages. When using jQuery, you often encounter situations where you need to replace the class name of an element. This article will introduce some practical methods and specific code examples. 1. Use the removeClass() and addClass() methods jQuery provides the removeClass() method for deletion

Detailed explanation of PHP Class usage: Make your code clearer and easier to read Detailed explanation of PHP Class usage: Make your code clearer and easier to read Mar 10, 2024 pm 12:03 PM

When writing PHP code, using classes is a very common practice. By using classes, we can encapsulate related functions and data in a single unit, making the code clearer, easier to read, and easier to maintain. This article will introduce the usage of PHPClass in detail and provide specific code examples to help readers better understand how to apply classes to optimize code in actual projects. 1. Create and use classes In PHP, you can use the keyword class to define a class and define properties and methods in the class.

What are the differences between cellpadding and cellspacing? What are the differences between cellpadding and cellspacing? Nov 27, 2023 am 10:35 AM

The difference between cellpadding and cellspacing: 1. Range of influence; 2. Object of action; 3. Attribute value. Detailed introduction: 1. Scope of influence. Cellpadding affects the distance between the internal content of the cell and the cell border, that is, the blank space within the cell. Cellspacing affects the spacing between adjacent cells, that is, the blank space between cells. ; 2. Action object, cellpadding acts on the inside of the cell, used to control the distance between the internal content of the cell and the border, etc.

Vue error: Unable to use v-bind to bind class and style correctly, how to solve it? Vue error: Unable to use v-bind to bind class and style correctly, how to solve it? Aug 26, 2023 pm 10:58 PM

Vue error: Unable to use v-bind to bind class and style correctly, how to solve it? In Vue development, we often use the v-bind instruction to dynamically bind class and style, but sometimes we may encounter some problems, such as being unable to correctly use v-bind to bind class and style. In this article, I will explain the cause of this problem and provide you with a solution. First, let’s understand the v-bind directive. v-bind is used to bind V

How to determine whether an element has a class in jquery How to determine whether an element has a class in jquery Mar 21, 2023 am 10:47 AM

How jquery determines whether an element has a class: 1. Determine whether an element has a certain class through the "hasClass('classname')" method; 2. Determine whether an element has a certain class through the "is('.classname')" method.

See all articles