PHP hyperlink capturing implementation code _ PHP Tutorial

Source: Internet
Author: User
PHP hyperlink capture implementation code. Common HTML standard hyperlink parameters get regular expression test because recently I want to do something similar to a professional search engine, I need to capture all the hyperlinks on the web page. Let's take a test of obtaining regular expressions for common HTML standard hyperlink parameters.
Because I recently want to create something similar to a professional search engine, I need to capture all the hyperlinks on the web page.
Let's test whether the following code can target all the standard hyperlinks.
The test code is as follows:

The code is as follows:


//--------------------------------------------------------------------------
// File name: Noname1.php
// Description: Test the regular expression for obtaining common link parameters.
// Requirement: PHP4 (http://www.php.net)
// Copyright (C), HonestQiao, 2005, All Rights Reserved.
// Author: HonestQiao (honestqiao@hotmail.com)
// Parameter description:
// $ StrSource: HTML webpage with standard link
// $ StrResult: processing result
// Additional description:
// The standard link and the link contained in the usage 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.

Because I recently want to create something similar to a professional search engine, I need to capture all the hyperlinks on the web page. Let's test it...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.