Regular expression-domain name rules on the php extraction page!

Source: Internet
Author: User
In a set of programs, all domain names must be extracted from the specified URL page. The modern CODE is as follows: & quot; $ CODE ......; get the remote URL content $ temp & quot; I & quot; preg_match_all ($ temp, $ CODE, $ Jzz_thlld); $ Jzz_thlld [0]; $ temp & quot; href [& quot; & #39;]? Http: \ www \. ([^ & gt; & quot; & #39;] +) [& quot; & #39;] regular php

In a program, all domain names must be extracted from the specified URL page. The modern code is as follows:

$ CODE = ......; // Obtain the remote URL content $ temp = "// I"; preg_match_all ($ temp, $ CODE, $ Jzz_thlld); $ Jzz_thlld = $ Jzz_thlld [0]; $ temp = "/href = [\" ']? Http: \/www \. ([^> \ "'] +) [\"']? \ S * [^>] *> (. *) <\/a>/si "; for ($ dos_skipping = 0; $ dos_skipping <sizeof ($ Jzz_thlld); $ dos_skipping ++) {preg_match ($ temp, $ Jzz_thlld [$ dos_skipping], $ tempurl); if (! ($ Tempurl [1]! = "")&&! (Strpos ($ tempurl [1], "? ") = FALSE )&&! (Strpos ($ tempurl [1], "&") === FALSE )&&! (Strpos ($ tempurl [1], "#") === FALSE )&&! (Strpos ($ tempurl [1], ":") === FALSE )&&! (Strpos ($ tempurl [1], "") = FALSE) {echo '99'; $ url_temp = "www. ". $ tempurl [1]; if (0 <strpos ($ url_temp, "/") {$ url_arr = explode ("/", $ url_temp ); $ url_temp = $ url_arr [0];} if ($ Jzz_cbgsf = "") {$ Jzz_cbgsf = $ url_temp;} else if (strpos ("| ". $ Jzz_cbgsf. "|", "| ". $ url_temp. "|") = FALSE) {$ Jzz_cbgsf. = "| ". $ url_temp ;}}}

The required information cannot be obtained in the above code as required. Please help us to see how to modify 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.