네이버의 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년 전 | 68 | ||
| 8229 | 9년 전 | 68 | ||
| 8228 |
커네드커네드
|
9년 전 | 112 | |
| 8227 | 9년 전 | 121 | ||
| 8226 | 9년 전 | 158 | ||
| 8225 | 9년 전 | 147 | ||
| 8224 | 9년 전 | 144 | ||
| 8223 | 9년 전 | 111 | ||
| 8222 |
|
9년 전 | 181 | |
| 8221 | 9년 전 | 87 | ||
| 8220 | 9년 전 | 100 | ||
| 8219 | 9년 전 | 97 | ||
| 8218 | 9년 전 | 135 | ||
| 8217 |
star3840
|
9년 전 | 109 | |
| 8216 | 9년 전 | 158 | ||
| 8215 | 9년 전 | 105 | ||
| 8214 | 9년 전 | 221 | ||
| 8213 | 9년 전 | 155 | ||
| 8212 | 9년 전 | 81 | ||
| 8211 | 9년 전 | 241 | ||
| 8210 | 9년 전 | 240 | ||
| 8209 | 9년 전 | 333 | ||
| 8208 | 9년 전 | 214 | ||
| 8207 | 9년 전 | 223 | ||
| 8206 |
|
9년 전 | 185 | |
| 8205 | 9년 전 | 168 | ||
| 8204 | 9년 전 | 129 | ||
| 8203 | 9년 전 | 230 | ||
| 8202 | 9년 전 | 138 | ||
| 8201 | 9년 전 | 177 | ||
| 8200 | 9년 전 | 157 | ||
| 8199 | 9년 전 | 210 | ||
| 8198 | 9년 전 | 172 | ||
| 8197 | 9년 전 | 162 | ||
| 8196 | 9년 전 | 551 | ||
| 8195 | 9년 전 | 154 | ||
| 8194 | 9년 전 | 280 | ||
| 8193 | 9년 전 | 153 | ||
| 8192 | 9년 전 | 183 | ||
| 8191 | 9년 전 | 136 | ||
| 8190 | 9년 전 | 126 | ||
| 8189 | 9년 전 | 188 | ||
| 8188 | 9년 전 | 125 | ||
| 8187 | 9년 전 | 139 | ||
| 8186 | 9년 전 | 139 | ||
| 8185 | 9년 전 | 306 | ||
| 8184 | 9년 전 | 106 | ||
| 8183 | 9년 전 | 322 | ||
| 8182 | 9년 전 | 165 | ||
| 8181 | 9년 전 | 127 | ||
| 8180 | 9년 전 | 690 | ||
| 8179 | 9년 전 | 480 | ||
| 8178 | 9년 전 | 309 | ||
| 8177 |
kiplayer
|
9년 전 | 310 | |
| 8176 | 9년 전 | 347 | ||
| 8175 | 9년 전 | 218 | ||
| 8174 | 9년 전 | 240 | ||
| 8173 | 9년 전 | 341 | ||
| 8172 | 9년 전 | 192 | ||
| 8171 | 9년 전 | 181 | ||
| 8170 | 9년 전 | 294 | ||
| 8169 |
커네드커네드
|
9년 전 | 256 | |
| 8168 | 9년 전 | 315 | ||
| 8167 | 9년 전 | 319 | ||
| 8166 | 9년 전 | 234 | ||
| 8165 | 9년 전 | 161 | ||
| 8164 | 9년 전 | 299 | ||
| 8163 | 9년 전 | 279 | ||
| 8162 | 9년 전 | 294 | ||
| 8161 | 9년 전 | 292 | ||
| 8160 |
|
9년 전 | 485 | |
| 8159 | 9년 전 | 424 | ||
| 8158 | 9년 전 | 246 | ||
| 8157 | 9년 전 | 371 | ||
| 8156 | 9년 전 | 273 | ||
| 8155 | 9년 전 | 249 | ||
| 8154 |
00년생용띠
|
9년 전 | 598 | |
| 8153 | 9년 전 | 227 | ||
| 8152 |
|
9년 전 | 402 | |
| 8151 | 9년 전 | 405 | ||
| 8150 | 9년 전 | 497 | ||
| 8149 |
Jangfolk
|
9년 전 | 346 | |
| 8148 | 9년 전 | 163 | ||
| 8147 | 9년 전 | 372 | ||
| 8146 | 9년 전 | 432 | ||
| 8145 | 9년 전 | 377 | ||
| 8144 | 9년 전 | 345 | ||
| 8143 | 9년 전 | 189 | ||
| 8142 | 9년 전 | 425 | ||
| 8141 | 9년 전 | 379 | ||
| 8140 | 9년 전 | 927 | ||
| 8139 | 9년 전 | 255 | ||
| 8138 |
전갈자리남자
|
9년 전 | 385 | |
| 8137 | 9년 전 | 393 | ||
| 8136 | 9년 전 | 743 | ||
| 8135 |
|
9년 전 | 791 | |
| 8134 |
PlayPixel
|
9년 전 | 508 | |
| 8133 |
|
9년 전 | 432 | |
| 8132 | 9년 전 | 444 | ||
| 8131 | 9년 전 | 808 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기