네이버의 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년 전 | 95 | ||
| 8229 | 9년 전 | 94 | ||
| 8228 |
커네드커네드
|
9년 전 | 139 | |
| 8227 | 9년 전 | 163 | ||
| 8226 | 9년 전 | 187 | ||
| 8225 | 9년 전 | 174 | ||
| 8224 | 9년 전 | 166 | ||
| 8223 | 9년 전 | 138 | ||
| 8222 |
|
9년 전 | 212 | |
| 8221 | 9년 전 | 121 | ||
| 8220 | 9년 전 | 139 | ||
| 8219 | 9년 전 | 119 | ||
| 8218 | 9년 전 | 166 | ||
| 8217 |
star3840
|
9년 전 | 135 | |
| 8216 | 9년 전 | 185 | ||
| 8215 | 9년 전 | 140 | ||
| 8214 | 9년 전 | 248 | ||
| 8213 | 9년 전 | 193 | ||
| 8212 | 9년 전 | 110 | ||
| 8211 | 9년 전 | 277 | ||
| 8210 | 9년 전 | 278 | ||
| 8209 | 9년 전 | 361 | ||
| 8208 | 9년 전 | 252 | ||
| 8207 | 9년 전 | 250 | ||
| 8206 |
|
9년 전 | 216 | |
| 8205 | 9년 전 | 198 | ||
| 8204 | 9년 전 | 160 | ||
| 8203 | 9년 전 | 253 | ||
| 8202 | 9년 전 | 167 | ||
| 8201 | 9년 전 | 203 | ||
| 8200 | 9년 전 | 193 | ||
| 8199 | 9년 전 | 238 | ||
| 8198 | 9년 전 | 202 | ||
| 8197 | 9년 전 | 187 | ||
| 8196 | 9년 전 | 578 | ||
| 8195 | 9년 전 | 185 | ||
| 8194 | 9년 전 | 311 | ||
| 8193 | 9년 전 | 190 | ||
| 8192 | 9년 전 | 223 | ||
| 8191 | 9년 전 | 171 | ||
| 8190 | 9년 전 | 167 | ||
| 8189 | 9년 전 | 227 | ||
| 8188 | 9년 전 | 159 | ||
| 8187 | 9년 전 | 170 | ||
| 8186 | 9년 전 | 167 | ||
| 8185 | 9년 전 | 341 | ||
| 8184 | 9년 전 | 129 | ||
| 8183 | 9년 전 | 343 | ||
| 8182 | 9년 전 | 198 | ||
| 8181 | 9년 전 | 162 | ||
| 8180 | 9년 전 | 730 | ||
| 8179 | 9년 전 | 510 | ||
| 8178 | 9년 전 | 340 | ||
| 8177 |
kiplayer
|
9년 전 | 353 | |
| 8176 | 9년 전 | 386 | ||
| 8175 | 9년 전 | 254 | ||
| 8174 | 9년 전 | 273 | ||
| 8173 | 9년 전 | 366 | ||
| 8172 | 9년 전 | 230 | ||
| 8171 | 9년 전 | 204 | ||
| 8170 | 9년 전 | 321 | ||
| 8169 |
커네드커네드
|
9년 전 | 283 | |
| 8168 | 9년 전 | 351 | ||
| 8167 | 9년 전 | 344 | ||
| 8166 | 9년 전 | 264 | ||
| 8165 | 9년 전 | 194 | ||
| 8164 | 9년 전 | 331 | ||
| 8163 | 9년 전 | 311 | ||
| 8162 | 9년 전 | 332 | ||
| 8161 | 9년 전 | 322 | ||
| 8160 |
|
9년 전 | 521 | |
| 8159 | 9년 전 | 457 | ||
| 8158 | 9년 전 | 278 | ||
| 8157 | 9년 전 | 402 | ||
| 8156 | 9년 전 | 289 | ||
| 8155 | 9년 전 | 279 | ||
| 8154 |
00년생용띠
|
9년 전 | 625 | |
| 8153 | 9년 전 | 259 | ||
| 8152 |
|
9년 전 | 435 | |
| 8151 | 9년 전 | 443 | ||
| 8150 | 9년 전 | 535 | ||
| 8149 |
Jangfolk
|
9년 전 | 375 | |
| 8148 | 9년 전 | 200 | ||
| 8147 | 9년 전 | 409 | ||
| 8146 | 9년 전 | 473 | ||
| 8145 | 9년 전 | 428 | ||
| 8144 | 9년 전 | 388 | ||
| 8143 | 9년 전 | 222 | ||
| 8142 | 9년 전 | 460 | ||
| 8141 | 9년 전 | 409 | ||
| 8140 | 9년 전 | 954 | ||
| 8139 | 9년 전 | 296 | ||
| 8138 |
전갈자리남자
|
9년 전 | 414 | |
| 8137 | 9년 전 | 429 | ||
| 8136 | 9년 전 | 774 | ||
| 8135 |
|
9년 전 | 818 | |
| 8134 |
PlayPixel
|
9년 전 | 545 | |
| 8133 |
|
9년 전 | 468 | |
| 8132 | 9년 전 | 488 | ||
| 8131 | 9년 전 | 838 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기