네이버의 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);
이렇게 바꿔주기만 하면 됩니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 1530 |
1111111
|
18년 전 | 1953 | |
| 1529 |
행복속네잎크로버
|
18년 전 | 3449 | |
| 1528 |
행복속네잎크로버
|
18년 전 | 1829 | |
| 1527 |
1111111
|
18년 전 | 7639 | |
| 1526 |
1111111
|
18년 전 | 3285 | |
| 1525 |
행복속네잎크로버
|
18년 전 | 1269 | |
| 1524 |
행복속네잎크로버
|
18년 전 | 2301 | |
| 1523 |
행복속네잎크로버
|
18년 전 | 3502 | |
| 1522 |
행복속네잎크로버
|
18년 전 | 2359 | |
| 1521 |
행복속네잎크로버
|
18년 전 | 2129 | |
| 1520 |
행복속네잎크로버
|
18년 전 | 2758 | |
| 1519 |
행복속네잎크로버
|
18년 전 | 3718 | |
| 1518 |
행복속네잎크로버
|
18년 전 | 3482 | |
| 1517 |
행복속네잎크로버
|
18년 전 | 2560 | |
| 1516 |
행복속네잎크로버
|
18년 전 | 1911 | |
| 1515 |
행복속네잎크로버
|
18년 전 | 1929 | |
| 1514 |
행복속네잎크로버
|
18년 전 | 2503 | |
| 1513 |
행복속네잎크로버
|
18년 전 | 1981 | |
| 1512 | 18년 전 | 2868 | ||
| 1511 | 18년 전 | 1660 | ||
| 1510 | 18년 전 | 2206 | ||
| 1509 | 18년 전 | 1679 | ||
| 1508 | 18년 전 | 2137 | ||
| 1507 | 18년 전 | 2356 | ||
| 1506 | 18년 전 | 2293 | ||
| 1505 | 18년 전 | 2246 | ||
| 1504 | 18년 전 | 2175 | ||
| 1503 | 18년 전 | 3483 | ||
| 1502 | 18년 전 | 1664 | ||
| 1501 | 18년 전 | 3440 | ||
| 1500 | 18년 전 | 2022 | ||
| 1499 | 18년 전 | 5291 | ||
| 1498 | 18년 전 | 2150 | ||
| 1497 |
hsp1980
|
18년 전 | 2332 | |
| 1496 |
hsp1980
|
18년 전 | 1723 | |
| 1495 |
hsp1980
|
18년 전 | 2132 | |
| 1494 |
hsp1980
|
18년 전 | 3645 | |
| 1493 | 18년 전 | 1499 | ||
| 1492 | 18년 전 | 1741 | ||
| 1491 | 18년 전 | 4317 | ||
| 1490 | 18년 전 | 3703 | ||
| 1489 | 18년 전 | 3263 | ||
| 1488 | 18년 전 | 3363 | ||
| 1487 |
mixdesign
|
18년 전 | 3864 | |
| 1486 |
mixdesign
|
18년 전 | 4324 | |
| 1485 | 18년 전 | 4246 | ||
| 1484 | 18년 전 | 2700 | ||
| 1483 |
hsp1980
|
18년 전 | 2309 | |
| 1482 |
hsp1980
|
18년 전 | 3245 | |
| 1481 |
hsp1980
|
18년 전 | 3162 | |
| 1480 |
hsp1980
|
18년 전 | 3317 | |
| 1479 | 18년 전 | 3256 | ||
| 1478 |
|
18년 전 | 4921 | |
| 1477 |
|
18년 전 | 5206 | |
| 1476 | 18년 전 | 3405 | ||
| 1475 |
mixdesign
|
18년 전 | 2716 | |
| 1474 |
mixdesign
|
18년 전 | 2939 | |
| 1473 |
mixdesign
|
18년 전 | 2266 | |
| 1472 |
mixdesign
|
18년 전 | 2084 | |
| 1471 |
mixdesign
|
18년 전 | 2034 | |
| 1470 |
|
18년 전 | 3072 | |
| 1469 |
mixdesign
|
18년 전 | 2353 | |
| 1468 |
mixdesign
|
18년 전 | 2373 | |
| 1467 |
mixdesign
|
18년 전 | 2049 | |
| 1466 |
mixdesign
|
18년 전 | 2419 | |
| 1465 |
mixdesign
|
18년 전 | 3151 | |
| 1464 | 18년 전 | 4081 | ||
| 1463 | 18년 전 | 3370 | ||
| 1462 |
|
18년 전 | 1998 | |
| 1461 |
|
18년 전 | 1940 | |
| 1460 | 18년 전 | 2857 | ||
| 1459 | 18년 전 | 1649 | ||
| 1458 |
|
18년 전 | 2001 | |
| 1457 |
mixdesign
|
18년 전 | 2293 | |
| 1456 |
mixdesign
|
18년 전 | 2156 | |
| 1455 | 18년 전 | 2264 | ||
| 1454 | 18년 전 | 4033 | ||
| 1453 | 18년 전 | 1773 | ||
| 1452 | 18년 전 | 4387 | ||
| 1451 | 18년 전 | 2920 | ||
| 1450 | 18년 전 | 2216 | ||
| 1449 | 18년 전 | 3267 | ||
| 1448 | 18년 전 | 2894 | ||
| 1447 | 18년 전 | 2823 | ||
| 1446 | 18년 전 | 5625 | ||
| 1445 | 18년 전 | 2291 | ||
| 1444 | 18년 전 | 3408 | ||
| 1443 |
|
18년 전 | 3321 | |
| 1442 | 18년 전 | 3707 | ||
| 1441 | 18년 전 | 3262 | ||
| 1440 | 18년 전 | 2437 | ||
| 1439 | 18년 전 | 2087 | ||
| 1438 | 18년 전 | 2540 | ||
| 1437 | 18년 전 | 6107 | ||
| 1436 | 18년 전 | 2732 | ||
| 1435 | 18년 전 | 4544 | ||
| 1434 | 18년 전 | 2041 | ||
| 1433 | 18년 전 | 10029 | ||
| 1432 | 18년 전 | 2475 | ||
| 1431 |
Psychedelico
|
18년 전 | 1538 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기