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. "
";}}