Home > Backend Development > PHP Tutorial > What is a hyperlink? PHP hyperlink crawling implementation code

What is a hyperlink? PHP hyperlink crawling implementation code

WBOY
Release: 2016-07-29 08:40:11
Original
1253 people have browsed it

Common HTML standard hyperlink parameter acquisition regular expression test
Because I recently want to build something similar to a professional search engine, I need to crawl all the hyperlinks of the web page.
Please help me test whether the following code can target all standard hyperlinks.
The test code is as follows:

Copy the code The code is as follows:


// -------------------------- --------------------------------------------------
// File name: Noname1.php
// Description: Common link parameter acquisition regular expression test
// Requirement: PHP4 (http://www.php.net)
// Copyright(C), HonestQiao, 2005 , All Rights Reserved.
// Author: HonestQiao (honestqiao@hotmail.com)
// Parameter description:
// $strSource: HTML webpage containing standard links
// $strResult: Processed result
// Additional instructions :
// Standard link, use the link contained in the situation
// -------------------------- ---------------------------------------------
$ strSource = <<t1
t2
t3
t4
HTML;
preg_match_all('/(.+?)/sim', $strSource, $strResult, PREG_PATTERN_ORDER);
for($i = 0; $i < count($strResult[1]); $i++)
{
printf("%d href=(%s) title=(%s) n", $i, $strResult[1][$i], $strResult[2][$i]);
}
?>


If you The test data conforms to the standard link, but is not processed here. Please tell me the test data and your test environment.
Thank you.

The above introduces what is a hyperlink and PHP hyperlink crawling implementation code, including what is a hyperlink. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template