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('/
for($i = 0; $i < count($strResult[1]); $i++)
{
printf("%d href=(%s) title=(%s) n", $i, $strResult[1][$i], $strResult[2][$i]);
}
?>
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.