Help, about PHP capture URL address

Source: Internet
Author: User
I want to collect all the posts URL address on the following page
Http://www.discuz.net/forum-10-1.html


The post format is
Http://www.discuz.net/thread-3265731-1-1.html


As long as the URL is linked, the result is one line


Reply to discussion (solution)

$url = ' http://www.discuz.net/forum-10-1.html '; $ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch , Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_useragent, ' mozilla/5.0 (Windows; U Windows NT 5.1; En-us; rv:1.9.2) gecko/20100115 firefox/3.6 (. NET CLR 3.5.30729), $htmls = Curl_exec ($ch); Curl_close ($ch); $doc = new DOMDocument (); Libxml_use_internal_errors (true), $doc->loadhtml ($htmls), $xpath = new Domxpath ($doc); $nodeList = $ Xpath->query ('//a/@href '); for ($i = 0; $i < $nodeList->length; $i + +) {if (Preg_match (' @\/thread\-@ ', $nodeList- >item ($i)->value, $match) {echo $nodeList->item ($i)->value. "
";}}
  • 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.