国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial 正則表述提取標(biāo)簽屬性值

正則表述提取標(biāo)簽屬性值

Jun 13, 2016 pm 01:06 PM
quot spider title

正則表達(dá)提取標(biāo)簽屬性值
如何用正則表達(dá)是提t(yī)itle的值“The Amazing Spider-Man (2012)”呢?
我自己是用兩次preg_split取的,但感覺很低效,有沒有朋友給點(diǎn)思路呢?

HTML code
<!--

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

-->
<td class="image">
    <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)"></a>
  </td>



------解決方案--------------------
PHP code

<?php $str='<td class="image">
    <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)"></a>
    <a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)">
  ';
$patten = '/title="(.*)"/Uis';
if (preg_match ( $patten, $str, $array )) {
print_r($array);
}
echo "<br>";
$patten1 = '/</a><a href=".*" title="(.*)">/Uis';
if (preg_match_all ( $patten1, $str, $array1 )) {
print_r($array1[1]);
}
?>
<br><font color="#e78608">------解決方案--------------------</font><br>
<dl class="code">PHP code<pre class="brush:php;toolbar:false">

$string='<td class="image">
<a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)1"><img src="/static/imghw/default1.png" data-src="http://ia.media-imdb.com/images/M/MV5BMjMyOTM4MDMxNV5BMl5BanBnXkFtZTcwNjIyNzExOA@@._V1._SX54_CR0,0,54,74_.jpg" class="lazy"    style="max-width:90%"  style="max-width:90%" alt="The Amazing Spider-Man (2012)" title="The Amazing Spider-Man (2012)3"></a><a href="/title/tt0948470/" title="The Amazing Spider-Man (2012)2"></a>
</td>'; 
    if (preg_match_all ( '/(?array(2) {
  [0]=>
  array(3) {
    [0]=>
    string(38) "title="The Amazing Spider-Man (2012)1""
    [1]=>
    string(38) "title="The Amazing Spider-Man (2012)3""
    [2]=>
    string(38) "title="The Amazing Spider-Man (2012)2""
  }
  [1]=>
  array(3) {
    [0]=>
    string(30) "The Amazing Spider-Man (2012)1"
    [1]=>
    string(30) "The Amazing Spider-Man (2012)3"
    [2]=>
    string(30) "The Amazing Spider-Man (2012)2"
  }
}

    */ <div class="clear">
                 
              
              
        
            </div>
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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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)

what does title mean what does title mean Aug 04, 2023 am 11:18 AM

Title is the meaning that defines the title of the web page. It is located within the tag and is the text displayed in the title bar of the browser. Title is very important for the search engine optimization and user experience of the web page. When writing HTML web pages, you should pay attention to using relevant keywords and attractive descriptions to define the title element to attract more users to click and browse.

php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出,該如何解決 php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出,該如何解決 Jun 13, 2016 am 10:23 AM

php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出php提交表單通過后,彈出的對話框怎樣在當(dāng)前頁彈出而不是在空白頁彈出?想實(shí)現(xiàn)這樣的效果:而不是空白頁彈出:------解決方案--------------------如果你的驗(yàn)證用PHP在后端,那么就用Ajax;僅供參考:HTML code

What is the meaning of title in HTML What is the meaning of title in HTML Mar 06, 2024 am 09:53 AM

The title in HTML displays the title tag of the web page, which allows the viewer to know what the current page is about, so each web page should have a separate title.

How Scrapy Spider supports multiple web page parsing methods How Scrapy Spider supports multiple web page parsing methods Jun 22, 2023 am 11:17 AM

Scrapy is a powerful web crawler framework written in Python. It can help us extract web page information, automatically operate the content and data on the website, and can handle large-scale data crawling and processing tasks in a very efficient manner. Scrapy provides a powerful Spider framework, API and plug-ins for easy use and extension. In this article, we will introduce how to support multiple web page parsing methods in ScrapySpider. Before we start, we need to understand some basics

phpSpider practical tips: How to deal with dynamic loading of web content? phpSpider practical tips: How to deal with dynamic loading of web content? Jul 22, 2023 am 08:33 AM

phpSpider practical tips: How to deal with dynamic loading of web content? When crawling web page data, we often encounter the problem that dynamically loaded content cannot be obtained directly through the crawler. These dynamically loaded contents can be data obtained through AJAX requests, DOM elements rendered through JavaScript, etc. In order to solve this problem, this article will introduce some practical tips for dealing with dynamic loading problems of web pages when using phpSpider. 1. Use network debugging tools to find dynamically loaded URLs

圖片消失怎么解決 圖片消失怎么解決 Apr 07, 2024 pm 03:02 PM

圖片消失如何解決先是圖片文件上傳$file=$_FILES['userfile']; ?if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

phpSpider Advanced Guide: How to implement data crawling that maintains login status? phpSpider Advanced Guide: How to implement data crawling that maintains login status? Jul 21, 2023 pm 04:13 PM

phpSpider Advanced Guide: How to implement data crawling that maintains login status? In recent years, with the rapid development of the Internet, data crawling plays an important role in various application scenarios. For some websites that require a login state, it is particularly important to implement data crawling in the login state. This article will introduce how to use phpSpider to implement data crawling that maintains login status, and give corresponding code examples. 1. Overview phpSpider is a high-performance, low-coupling, and support system developed based on PHP language.

不用數(shù)據(jù)庫來實(shí)現(xiàn)用戶的簡單的下載,代碼如下,但是卻不能下載,請高手找下原因,文件路勁什么的沒有關(guān)問題 不用數(shù)據(jù)庫來實(shí)現(xiàn)用戶的簡單的下載,代碼如下,但是卻不能下載,請高手找下原因,文件路勁什么的沒有關(guān)問題 Jun 13, 2016 am 10:15 AM

不用數(shù)據(jù)庫來實(shí)現(xiàn)用戶的簡單的下載,代碼如下,但是卻不能下載,請高手找下原因,文件路勁什么的沒問題。

See all articles