야후 이용!Search API 자체 검색엔진-php 버 전 개발
"; echo " Line : " . $errorline['line'] . "
"; echo " Column : " . $errorline['col'] . "
"; } done();}// Now traverse the DOM with this function// It is basically a generic parser that turns limited XML into a PHP array// with only a couple of hardcoded tags which are common across all the// result xml from the web servicesfunction xml_to_result($dom) { $root = $dom->document_element(); $res['totalResultsAvailable'] = $root->get_attribute('totalResultsAvailable'); $res['totalResultsReturned'] = $root->get_attribute('totalResultsReturned'); $res['firstResultPosition'] = $root->get_attribute('firstResultPosition'); $node = $root->first_child(); $i = 0; while($node) { switch($node->tagname) { case 'Result': $subnode = $node->first_child(); while($subnode) { $subnodes = $subnode->child_nodes(); if(!empty($subnodes)) foreach($subnodes as $k=>$n) { if(empty($n->tagname)) $res[$i][$subnode->tagname] = trim($n->get_content()); else $res[$i][$subnode->tagname][$n->tagname]=trim($n->get_content()); } $subnode = $subnode->next_sibling(); } break; default: $res[$node->tagname] = trim($node->get_content()); $i--; break; } $i++; $node = $node->next_sibling(); } return $res;}$res = xml_to_result($dom);// Ok, now that we have the results in an easy to use format,// display them. It's quite ugly because I am using a single// display loop to display every type and I don't really understand HTML$first = $res['firstResultPosition'];$last = $first + $res['totalResultsReturned']-1;echo "
Matched ${res[totalResultsAvailable]}, showing $first to $last
";if(!empty($res['ResultSetMapUrl'])) { echo "Result Set Map: ${res[ResultSetMapUrl]}
";}for($i=0; $i<$res['totalResultsReturned']; $i++) { foreach($res[$i] as $key=>$value) { switch($key) { case 'Thumbnail': echo ""; break; case 'Cache': echo "Cache: ${value[Url]} [${value[Size]}]"; break; case 'PublishDate': echo "$key: ".strftime('%X %x',$value); break; default: if(stristr($key,'url')) echo "$value
"; else echo "$key: $value
"; break; } } echo "
";}// Create Previous/Next Page linksif($start > 1) echo '<-Previous Page ';if($last < $res['totalResultsAvailable']) echo 'Next Page->';done();?>관심 있 는 분 들 은[동적 사이트 제작 가이드]가 만 든 ASP 버 전도 보 실 수 있 습 니 다.http://www.knowsky.com/yahoo/