PHP实现抓取网页的所有超链接的代码
因为最近要做一个类似专业搜索引擎的东西,需要抓取网页的所有超链接。大家帮忙测试一下子,下面的代码是否可以针对所有的标准超链接。
通用HTML标准超链接参数取得正则表达式测试
因为最近要做一个类似专业搜索引擎的东西,需要抓取网页的所有超链接。
大家帮忙测试一下子,下面的代码是否可以针对所有的标准超链接。
测试代码如下:
<?php <br/>// -------------------------------------------------------------------------- <br>// File name : Noname1.php <br>// Description : 通用链接参数获取正则表达式测试 <br>// Requirement : PHP4 (http://www.php.net) <br>// Copyright(C), HonestQiao, 2005, All Rights Reserved. <br>// Author: HonestQiao (honestqiao@hotmail.com) <br>// 参数说明: <br>// $strSource: 包含标准链接的HTML网页 <br>// $strResult: 处理的结果 <br>// 附加说明: <br>// 标准链接,使用<a></a>形势包含的链接 <br>// -------------------------------------------------------------------------- <br>$strSource = <a>t1</a> <br><a>t2</a> <br><a>t3</a> <br><a>t4</a> <br>HTML; <br>preg_match_all('/<a.>(.+?)/sim', $strSource, $strResult, PREG_PATTERN_ORDER); <br>for($i = 0; $i { <br> printf("%d href=(%s) title=(%s) \n", $i, $strResult[1][$i], $strResult[2][$i]); <br>} <br> <br>?></a.>
Copy after login
如果您的测试数据,符合标准链接,但是此处没有被处理出来,请告诉我测试数据,以及你的测试环境。
谢谢。
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
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article
How to fix KB5055523 fails to install in Windows 11?
3 weeks ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks ago
By DDD
Roblox: Dead Rails - How To Tame Wolves
4 weeks ago
By DDD
Strength Levels for Every Enemy & Monster in R.E.P.O.
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Roblox: Grow A Garden - Complete Mutation Guide
2 weeks ago
By DDD

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics
Java Tutorial
1660
14


CakePHP Tutorial
1416
52


Laravel Tutorial
1311
25


PHP Tutorial
1261
29


C# Tutorial
1234
24

