네이버의 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);
이렇게 바꿔주기만 하면 됩니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 9년 전 | 417 | ||
| 7829 |
|
9년 전 | 611 | |
| 7828 | 9년 전 | 537 | ||
| 7827 | 9년 전 | 427 | ||
| 7826 | 9년 전 | 433 | ||
| 7825 | 10년 전 | 478 | ||
| 7824 | 10년 전 | 444 | ||
| 7823 | 10년 전 | 380 | ||
| 7822 | 10년 전 | 356 | ||
| 7821 | 10년 전 | 307 | ||
| 7820 | 10년 전 | 347 | ||
| 7819 |
|
10년 전 | 751 | |
| 7818 | 10년 전 | 386 | ||
| 7817 | 10년 전 | 518 | ||
| 7816 | 10년 전 | 407 | ||
| 7815 | 10년 전 | 608 | ||
| 7814 | 10년 전 | 432 | ||
| 7813 | 10년 전 | 373 | ||
| 7812 | 10년 전 | 398 | ||
| 7811 | 10년 전 | 391 | ||
| 7810 | 10년 전 | 563 | ||
| 7809 | 10년 전 | 491 | ||
| 7808 | 10년 전 | 375 | ||
| 7807 | 10년 전 | 402 | ||
| 7806 |
프로그래머7
|
10년 전 | 1332 | |
| 7805 | 10년 전 | 1275 | ||
| 7804 |
zahir1312
|
10년 전 | 777 | |
| 7803 |
|
10년 전 | 1373 | |
| 7802 | 10년 전 | 457 | ||
| 7801 | 10년 전 | 858 | ||
| 7800 | 10년 전 | 1084 | ||
| 7799 | 10년 전 | 555 | ||
| 7798 | 10년 전 | 508 | ||
| 7797 | 10년 전 | 504 | ||
| 7796 | 10년 전 | 350 | ||
| 7795 | 10년 전 | 501 | ||
| 7794 | 10년 전 | 549 | ||
| 7793 | 10년 전 | 1055 | ||
| 7792 | 10년 전 | 469 | ||
| 7791 | 10년 전 | 553 | ||
| 7790 | 10년 전 | 503 | ||
| 7789 |
fbastore
|
10년 전 | 1448 | |
| 7788 | 10년 전 | 544 | ||
| 7787 | 10년 전 | 398 | ||
| 7786 | 10년 전 | 585 | ||
| 7785 | 10년 전 | 583 | ||
| 7784 | 10년 전 | 644 | ||
| 7783 | 10년 전 | 444 | ||
| 7782 | 10년 전 | 489 | ||
| 7781 | 10년 전 | 898 | ||
| 7780 | 10년 전 | 813 | ||
| 7779 | 10년 전 | 775 | ||
| 7778 | 10년 전 | 364 | ||
| 7777 | 10년 전 | 453 | ||
| 7776 | 10년 전 | 459 | ||
| 7775 | 10년 전 | 407 | ||
| 7774 | 10년 전 | 631 | ||
| 7773 | 10년 전 | 380 | ||
| 7772 | 10년 전 | 733 | ||
| 7771 | 10년 전 | 386 | ||
| 7770 | 10년 전 | 642 | ||
| 7769 | 10년 전 | 379 | ||
| 7768 | 10년 전 | 610 | ||
| 7767 | 10년 전 | 1170 | ||
| 7766 | 10년 전 | 491 | ||
| 7765 | 10년 전 | 523 | ||
| 7764 |
잘살아보자
|
10년 전 | 387 | |
| 7763 |
|
10년 전 | 1457 | |
| 7762 |
Tosea
|
10년 전 | 1051 | |
| 7761 | 10년 전 | 644 | ||
| 7760 |
잘살아보자
|
10년 전 | 675 | |
| 7759 |
잘살아보자
|
10년 전 | 505 | |
| 7758 |
잘살아보자
|
10년 전 | 591 | |
| 7757 | 10년 전 | 1245 | ||
| 7756 |
ITBANK
|
10년 전 | 1252 | |
| 7755 | 10년 전 | 1929 | ||
| 7754 | 10년 전 | 1052 | ||
| 7753 | 10년 전 | 884 | ||
| 7752 | 10년 전 | 1391 | ||
| 7751 |
잘살아보자
|
10년 전 | 529 | |
| 7750 |
잘살아보자
|
10년 전 | 475 | |
| 7749 |
잘살아보자
|
10년 전 | 488 | |
| 7748 |
잘살아보자
|
10년 전 | 493 | |
| 7747 |
잘살아보자
|
10년 전 | 586 | |
| 7746 |
잘살아보자
|
10년 전 | 673 | |
| 7745 |
잘살아보자
|
10년 전 | 916 | |
| 7744 |
잘살아보자
|
10년 전 | 415 | |
| 7743 | 10년 전 | 946 | ||
| 7742 |
starbros
|
10년 전 | 840 | |
| 7741 |
잘살아보자
|
10년 전 | 671 | |
| 7740 |
잘살아보자
|
10년 전 | 535 | |
| 7739 |
잘살아보자
|
10년 전 | 465 | |
| 7738 |
잘살아보자
|
10년 전 | 531 | |
| 7737 |
잘살아보자
|
10년 전 | 499 | |
| 7736 |
잘살아보자
|
10년 전 | 522 | |
| 7735 |
잘살아보자
|
10년 전 | 850 | |
| 7734 |
잘살아보자
|
10년 전 | 429 | |
| 7733 |
잘살아보자
|
10년 전 | 542 | |
| 7732 |
잘살아보자
|
10년 전 | 695 | |
| 7731 |
잘살아보자
|
10년 전 | 620 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기