您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

求助,关于php采集url地址

2024/3/29 22:35:29发布15次查看
我想在如下网页采集所有的帖子url地址
http://www.discuz.net/forum-10-1.html
帖子格式为
http://www.discuz.net/thread-3265731-1-1.html
只要url链接,得出的结果一行一个
回复讨论(解决方案) $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 length; $i++) { if(preg_match('@\/thread\-@',$nodelist->item($i)->value,$match)){ echo $nodelist->item($i)->value.
; }}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product