Generic HTML standard hyperlink parameter get regular expression test
Because I'm going to do something like a professional search engine recently, I need to crawl all the hyperlinks in the web.
Everyone help test all of a sudden, the following code can be for all the standard hyperlinks.
The test code is as follows:
Copy the Code code as follows:
// --------------------------------------------------------------------------
File name:Noname1.php
Description: Generic link parameter get 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 pages that contain standard links
$strResult: Results of processing
Additional Instructions:
Standard links, using the links contained in the situation
// --------------------------------------------------------------------------
$strSource = <<t1
T2
T3
T4
HTML;
Preg_match_all ('/(. +?) <\/a.*?>/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 your test data conforms to the standard link, but is not processed here, please let me know the test data and your test environment.
Thank you.
The above describes what is a hyperlink to the PHP hyperlink crawl implementation code, including what is the content of hyperlinks, I hope the PHP tutorial interested in a friend helpful.