네이버의 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);
이렇게 바꿔주기만 하면 됩니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7930 | 9년 전 | 445 | ||
| 7929 | 9년 전 | 377 | ||
| 7928 | 9년 전 | 462 | ||
| 7927 | 9년 전 | 373 | ||
| 7926 | 9년 전 | 681 | ||
| 7925 | 9년 전 | 395 | ||
| 7924 | 9년 전 | 380 | ||
| 7923 | 9년 전 | 374 | ||
| 7922 | 9년 전 | 409 | ||
| 7921 | 9년 전 | 421 | ||
| 7920 | 9년 전 | 340 | ||
| 7919 | 9년 전 | 349 | ||
| 7918 | 9년 전 | 502 | ||
| 7917 | 9년 전 | 353 | ||
| 7916 | 9년 전 | 440 | ||
| 7915 | 9년 전 | 444 | ||
| 7914 | 9년 전 | 454 | ||
| 7913 | 9년 전 | 628 | ||
| 7912 | 9년 전 | 461 | ||
| 7911 | 9년 전 | 392 | ||
| 7910 | 9년 전 | 440 | ||
| 7909 | 9년 전 | 540 | ||
| 7908 | 9년 전 | 483 | ||
| 7907 | 9년 전 | 420 | ||
| 7906 | 9년 전 | 440 | ||
| 7905 | 9년 전 | 406 | ||
| 7904 | 9년 전 | 393 | ||
| 7903 | 9년 전 | 391 | ||
| 7902 | 9년 전 | 587 | ||
| 7901 |
|
9년 전 | 764 | |
| 7900 | 9년 전 | 642 | ||
| 7899 | 9년 전 | 426 | ||
| 7898 | 9년 전 | 424 | ||
| 7897 | 9년 전 | 381 | ||
| 7896 | 9년 전 | 396 | ||
| 7895 | 9년 전 | 508 | ||
| 7894 | 9년 전 | 425 | ||
| 7893 | 9년 전 | 398 | ||
| 7892 | 9년 전 | 434 | ||
| 7891 | 9년 전 | 796 | ||
| 7890 | 9년 전 | 1225 | ||
| 7889 | 9년 전 | 762 | ||
| 7888 |
limsy1987
|
9년 전 | 573 | |
| 7887 | 9년 전 | 602 | ||
| 7886 | 9년 전 | 492 | ||
| 7885 | 9년 전 | 456 | ||
| 7884 | 9년 전 | 450 | ||
| 7883 | 9년 전 | 455 | ||
| 7882 | 9년 전 | 515 | ||
| 7881 | 9년 전 | 483 | ||
| 7880 | 9년 전 | 610 | ||
| 7879 | 9년 전 | 498 | ||
| 7878 | 9년 전 | 1272 | ||
| 7877 | 9년 전 | 796 | ||
| 7876 | 9년 전 | 531 | ||
| 7875 | 9년 전 | 608 | ||
| 7874 |
|
9년 전 | 825 | |
| 7873 | 9년 전 | 542 | ||
| 7872 | 9년 전 | 710 | ||
| 7871 | 9년 전 | 525 | ||
| 7870 | 9년 전 | 646 | ||
| 7869 | 9년 전 | 458 | ||
| 7868 | 9년 전 | 496 | ||
| 7867 | 9년 전 | 493 | ||
| 7866 | 9년 전 | 546 | ||
| 7865 | 9년 전 | 487 | ||
| 7864 | 9년 전 | 554 | ||
| 7863 | 9년 전 | 549 | ||
| 7862 | 9년 전 | 503 | ||
| 7861 | 9년 전 | 687 | ||
| 7860 | 9년 전 | 658 | ||
| 7859 | 9년 전 | 438 | ||
| 7858 | 9년 전 | 740 | ||
| 7857 | 9년 전 | 1127 | ||
| 7856 | 9년 전 | 560 | ||
| 7855 | 9년 전 | 787 | ||
| 7854 | 9년 전 | 744 | ||
| 7853 | 9년 전 | 636 | ||
| 7852 | 9년 전 | 558 | ||
| 7851 | 9년 전 | 545 | ||
| 7850 | 9년 전 | 628 | ||
| 7849 | 9년 전 | 392 | ||
| 7848 | 9년 전 | 460 | ||
| 7847 | 9년 전 | 702 | ||
| 7846 | 9년 전 | 491 | ||
| 7845 | 9년 전 | 462 | ||
| 7844 | 9년 전 | 431 | ||
| 7843 | 9년 전 | 469 | ||
| 7842 | 9년 전 | 445 | ||
| 7841 | 9년 전 | 424 | ||
| 7840 | 9년 전 | 433 | ||
| 7839 | 9년 전 | 478 | ||
| 7838 | 9년 전 | 542 | ||
| 7837 | 9년 전 | 381 | ||
| 7836 | 9년 전 | 436 | ||
| 7835 | 10년 전 | 510 | ||
| 7834 |
|
10년 전 | 1221 | |
| 7833 | 10년 전 | 480 | ||
| 7832 | 10년 전 | 455 | ||
| 7831 | 10년 전 | 614 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기