<?PHP header("Content-type:text/html; Charset=utf-8"); $q='%E6%95%99%E5%B8%88'; $url="http://www.zhgongyf.com/tools/xmloutput.aspx?q='.$q.'&ishighlight=0&site=zhuangti"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $xmldata = curl_exec($ch); curl_close($ch); $xml_obj = simplexml_load_string($xmldata, 'SimpleXMLElement', LIBXML_NOCDATA); $result =$xml_obj->results->doc; if(!$result)exit; echo('<div class="zhuanti"><h2>相关专题</h2><ul>'); foreach($result as $rt){ $title = $rt->title; $url = $rt->url; if ($title) print_r('<li><a href="'.$url.'" target="_blank">'.$title.'</a></li>'); } echo('</ul></div>'); die(); ?>