네이버의 openapi에서 키를 받으셔야 사용할수 있습니다.
궁금한 점은 http://openapi.naver.com/15.html 이곳에서 확인하세요.
결과가 간단하므로 복잡하게 처리하지 않고 간단하게 처리햇습니다.
php에서 fopen(), iconv()를 지원하는 환경에서만 가능합니다.
이하 소스
-----------------------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=euc-kr'>
<title> 인기검색어 </title>
</head>
<body>
<center>
<table width=200 border=1 cellspacing=3>
<?php
$naver_openapi_key = '자신이 네이버에서 발급받은 키를 넣으세요';
$file = 'http://openapi.naver.com/search?key=' . $naver_openapi_key . '&query=nexearch&target=rank';
$fp = fopen($file, 'r') or die($file . ' not found');
$text = '';
while($data = fread($fp, 4096)){
$text .= iconv('UTF-8', 'EUC-KR', $data);
}
fclose($fp);
preg_match_all("'<K>([^<]*)</K>[^<]*<S>([^<]*)</S>[^<]*<V>([^<]*)</V>'s", $text, $matches);
if (is_array($matches[1]) && count($matches[1]) > 0){
foreach($matches[1] as $key => $val){
echo "<tr align='center'><td> " . $val . " </td><td> " . $matches[2][$key] . " </td><td> " . $matches[3][$key] . " </td></tr>";
}
}
else echo "<tr><td>검색결과 없음</td></tr>";
?>
</table>
<br><a href='http://openapi.naver.com/' target='_blank'>네이버 OPENAPI 사용</a>
</center>
</body>
</html>
-----------------------------------------------------------------------------------------------------------
utf-8 환경에서 사용할려면
<meta http-equiv='Content-Type' content='text/html; charset=euc-kr'> 을
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> 로 바꾸고
$text .= iconv('UTF-8', 'EUC-KR', $data); 을
$text .= $data; 로 바꾸시면 됩니다.
데모로 걸은 링크 사이트는 며칠후에는 안보일수 있습니다
http://search.dyd.cc/favorites_word.php<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
궁금한 점은 http://openapi.naver.com/15.html 이곳에서 확인하세요.
결과가 간단하므로 복잡하게 처리하지 않고 간단하게 처리햇습니다.
php에서 fopen(), iconv()를 지원하는 환경에서만 가능합니다.
이하 소스
-----------------------------------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=euc-kr'>
<title> 인기검색어 </title>
</head>
<body>
<center>
<table width=200 border=1 cellspacing=3>
<?php
$naver_openapi_key = '자신이 네이버에서 발급받은 키를 넣으세요';
$file = 'http://openapi.naver.com/search?key=' . $naver_openapi_key . '&query=nexearch&target=rank';
$fp = fopen($file, 'r') or die($file . ' not found');
$text = '';
while($data = fread($fp, 4096)){
$text .= iconv('UTF-8', 'EUC-KR', $data);
}
fclose($fp);
preg_match_all("'<K>([^<]*)</K>[^<]*<S>([^<]*)</S>[^<]*<V>([^<]*)</V>'s", $text, $matches);
if (is_array($matches[1]) && count($matches[1]) > 0){
foreach($matches[1] as $key => $val){
echo "<tr align='center'><td> " . $val . " </td><td> " . $matches[2][$key] . " </td><td> " . $matches[3][$key] . " </td></tr>";
}
}
else echo "<tr><td>검색결과 없음</td></tr>";
?>
</table>
<br><a href='http://openapi.naver.com/' target='_blank'>네이버 OPENAPI 사용</a>
</center>
</body>
</html>
-----------------------------------------------------------------------------------------------------------
utf-8 환경에서 사용할려면
<meta http-equiv='Content-Type' content='text/html; charset=euc-kr'> 을
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'> 로 바꾸고
$text .= iconv('UTF-8', 'EUC-KR', $data); 을
$text .= $data; 로 바꾸시면 됩니다.
데모로 걸은 링크 사이트는 며칠후에는 안보일수 있습니다
http://search.dyd.cc/favorites_word.php<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
댓글 4개
19년 전
좋은 팁들 감사드립니다.
혹시 검색어에 링크가 되게할 수는 없는지요.
혹시 검색어에 링크가 되게할 수는 없는지요.
19년 전
네 물론 가능하지요
foreach 부분을 다음과 같이 고쳐 주시면 됩니다.
----------------------------------------------------------------------------------------------------------------------------------------------------
foreach($matches[1] as $key => $val){
$link = 'http://search.naver.com/search.naver?where=nexearch&query=' . urlencode($val);
echo "<tr align='center'><td> <a href='" . $link . "' target='_blank'>" . $val . "</a> </td><td> " . $matches[2][$key] . " </td><td> " . $matches[3][$key] . " </td></tr>";
}
-------------------------------------------------------------------------------------------------------------------------------------------------------
foreach 부분을 다음과 같이 고쳐 주시면 됩니다.
----------------------------------------------------------------------------------------------------------------------------------------------------
foreach($matches[1] as $key => $val){
$link = 'http://search.naver.com/search.naver?where=nexearch&query=' . urlencode($val);
echo "<tr align='center'><td> <a href='" . $link . "' target='_blank'>" . $val . "</a> </td><td> " . $matches[2][$key] . " </td><td> " . $matches[3][$key] . " </td></tr>";
}
-------------------------------------------------------------------------------------------------------------------------------------------------------
19년 전
감사합니다. 바로 적용해주셨네요. 좋은 공부가 될 것 같습니다.
19년 전
웹검색으로 바로가게 할려면요
위의
$link = 'http://search.naver.com/search.naver?where=nexearch&query=' . urlencode($val);
부분을
$link = 'http://web.search.naver.com/search.naver?where=web&query=' . urlencode($val);
이렇게 바꿔주기만 하면 됩니다.
위의
$link = 'http://search.naver.com/search.naver?where=nexearch&query=' . urlencode($val);
부분을
$link = 'http://web.search.naver.com/search.naver?where=web&query=' . urlencode($val);
이렇게 바꿔주기만 하면 됩니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 141 | ||
| 8229 | 9년 전 | 125 | ||
| 8228 |
커네드커네드
|
9년 전 | 164 | |
| 8227 | 9년 전 | 210 | ||
| 8226 | 9년 전 | 225 | ||
| 8225 | 9년 전 | 205 | ||
| 8224 | 9년 전 | 210 | ||
| 8223 | 9년 전 | 177 | ||
| 8222 |
|
9년 전 | 252 | |
| 8221 | 9년 전 | 161 | ||
| 8220 | 9년 전 | 190 | ||
| 8219 | 9년 전 | 160 | ||
| 8218 | 9년 전 | 196 | ||
| 8217 |
star3840
|
9년 전 | 170 | |
| 8216 | 9년 전 | 241 | ||
| 8215 | 9년 전 | 184 | ||
| 8214 | 9년 전 | 292 | ||
| 8213 | 9년 전 | 250 | ||
| 8212 | 9년 전 | 159 | ||
| 8211 | 9년 전 | 336 | ||
| 8210 | 9년 전 | 336 | ||
| 8209 | 9년 전 | 408 | ||
| 8208 | 9년 전 | 300 | ||
| 8207 | 9년 전 | 303 | ||
| 8206 |
|
9년 전 | 257 | |
| 8205 | 9년 전 | 239 | ||
| 8204 | 9년 전 | 215 | ||
| 8203 | 9년 전 | 286 | ||
| 8202 | 9년 전 | 204 | ||
| 8201 | 9년 전 | 251 | ||
| 8200 | 9년 전 | 257 | ||
| 8199 | 9년 전 | 270 | ||
| 8198 | 9년 전 | 235 | ||
| 8197 | 9년 전 | 225 | ||
| 8196 | 9년 전 | 636 | ||
| 8195 | 9년 전 | 237 | ||
| 8194 | 9년 전 | 350 | ||
| 8193 | 9년 전 | 250 | ||
| 8192 | 9년 전 | 267 | ||
| 8191 | 9년 전 | 216 | ||
| 8190 | 9년 전 | 212 | ||
| 8189 | 9년 전 | 273 | ||
| 8188 | 9년 전 | 206 | ||
| 8187 | 9년 전 | 210 | ||
| 8186 | 9년 전 | 212 | ||
| 8185 | 9년 전 | 376 | ||
| 8184 | 9년 전 | 166 | ||
| 8183 | 9년 전 | 389 | ||
| 8182 | 9년 전 | 248 | ||
| 8181 | 9년 전 | 197 | ||
| 8180 | 9년 전 | 778 | ||
| 8179 | 9년 전 | 549 | ||
| 8178 | 9년 전 | 405 | ||
| 8177 |
kiplayer
|
9년 전 | 403 | |
| 8176 | 9년 전 | 435 | ||
| 8175 | 9년 전 | 326 | ||
| 8174 | 9년 전 | 319 | ||
| 8173 | 9년 전 | 405 | ||
| 8172 | 9년 전 | 287 | ||
| 8171 | 9년 전 | 249 | ||
| 8170 | 9년 전 | 370 | ||
| 8169 |
커네드커네드
|
9년 전 | 320 | |
| 8168 | 9년 전 | 404 | ||
| 8167 | 9년 전 | 395 | ||
| 8166 | 9년 전 | 294 | ||
| 8165 | 9년 전 | 241 | ||
| 8164 | 9년 전 | 369 | ||
| 8163 | 9년 전 | 367 | ||
| 8162 | 9년 전 | 367 | ||
| 8161 | 9년 전 | 383 | ||
| 8160 |
|
9년 전 | 583 | |
| 8159 | 9년 전 | 526 | ||
| 8158 | 9년 전 | 330 | ||
| 8157 | 9년 전 | 439 | ||
| 8156 | 9년 전 | 327 | ||
| 8155 | 9년 전 | 320 | ||
| 8154 |
00년생용띠
|
9년 전 | 658 | |
| 8153 | 9년 전 | 301 | ||
| 8152 |
|
9년 전 | 482 | |
| 8151 | 9년 전 | 478 | ||
| 8150 | 9년 전 | 584 | ||
| 8149 |
Jangfolk
|
9년 전 | 440 | |
| 8148 | 9년 전 | 256 | ||
| 8147 | 9년 전 | 447 | ||
| 8146 | 9년 전 | 530 | ||
| 8145 | 9년 전 | 479 | ||
| 8144 | 9년 전 | 444 | ||
| 8143 | 9년 전 | 281 | ||
| 8142 | 9년 전 | 490 | ||
| 8141 | 9년 전 | 441 | ||
| 8140 | 9년 전 | 997 | ||
| 8139 | 9년 전 | 349 | ||
| 8138 |
전갈자리남자
|
9년 전 | 454 | |
| 8137 | 9년 전 | 495 | ||
| 8136 | 9년 전 | 813 | ||
| 8135 |
|
9년 전 | 858 | |
| 8134 |
PlayPixel
|
9년 전 | 597 | |
| 8133 |
|
9년 전 | 508 | |
| 8132 | 9년 전 | 543 | ||
| 8131 | 9년 전 | 900 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기