네이버의 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);
이렇게 바꿔주기만 하면 됩니다.
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 1630 | 17년 전 | 2365 | ||
| 1629 | 17년 전 | 2836 | ||
| 1628 |
인스웨이브시스템즈
|
17년 전 | 4614 | |
| 1627 | 17년 전 | 2673 | ||
| 1626 |
silence
|
17년 전 | 1869 | |
| 1625 |
|
17년 전 | 3314 | |
| 1624 | 17년 전 | 3134 | ||
| 1623 | 17년 전 | 3855 | ||
| 1622 | 17년 전 | 2168 | ||
| 1621 | 17년 전 | 2342 | ||
| 1620 | 17년 전 | 9998 | ||
| 1619 | 17년 전 | 3497 | ||
| 1618 | 18년 전 | 3297 | ||
| 1617 | 18년 전 | 3186 | ||
| 1616 |
|
18년 전 | 2798 | |
| 1615 | 18년 전 | 4161 | ||
| 1614 |
에스카르고
|
18년 전 | 5503 | |
| 1613 | 18년 전 | 3736 | ||
| 1612 | 18년 전 | 3181 | ||
| 1611 | 18년 전 | 3604 | ||
| 1610 |
DHenny
|
18년 전 | 2256 | |
| 1609 | 18년 전 | 2685 | ||
| 1608 |
|
18년 전 | 3919 | |
| 1607 | 18년 전 | 2844 | ||
| 1606 |
|
18년 전 | 4354 | |
| 1605 | 18년 전 | 2073 | ||
| 1604 |
|
18년 전 | 2511 | |
| 1603 |
|
18년 전 | 2408 | |
| 1602 |
|
18년 전 | 3762 | |
| 1601 |
|
18년 전 | 3828 | |
| 1600 | 18년 전 | 2569 | ||
| 1599 | 18년 전 | 2639 | ||
| 1598 | 18년 전 | 2970 | ||
| 1597 |
|
18년 전 | 2800 | |
| 1596 |
|
18년 전 | 2008 | |
| 1595 |
|
18년 전 | 2181 | |
| 1594 | 18년 전 | 4830 | ||
| 1593 | 18년 전 | 4176 | ||
| 1592 | 18년 전 | 2800 | ||
| 1591 | 18년 전 | 2358 | ||
| 1590 | 18년 전 | 2862 | ||
| 1589 | 18년 전 | 2338 | ||
| 1588 |
|
18년 전 | 3500 | |
| 1587 | 18년 전 | 2171 | ||
| 1586 | 18년 전 | 1967 | ||
| 1585 | 18년 전 | 1823 | ||
| 1584 | 18년 전 | 1640 | ||
| 1583 | 18년 전 | 3236 | ||
| 1582 | 18년 전 | 4559 | ||
| 1581 | 18년 전 | 4838 | ||
| 1580 |
|
18년 전 | 2128 | |
| 1579 | 18년 전 | 3579 | ||
| 1578 | 18년 전 | 3303 | ||
| 1577 | 18년 전 | 4590 | ||
| 1576 | 18년 전 | 3235 | ||
| 1575 | 18년 전 | 4233 | ||
| 1574 |
개발전문가
|
18년 전 | 3921 | |
| 1573 |
mixdesign
|
18년 전 | 3609 | |
| 1572 |
mixdesign
|
18년 전 | 3009 | |
| 1571 |
mixdesign
|
18년 전 | 2905 | |
| 1570 | 18년 전 | 3482 | ||
| 1569 |
mixdesign
|
18년 전 | 2133 | |
| 1568 |
mixdesign
|
18년 전 | 2089 | |
| 1567 | 18년 전 | 5492 | ||
| 1566 |
mixdesign
|
18년 전 | 2668 | |
| 1565 |
mixdesign
|
18년 전 | 2408 | |
| 1564 | 18년 전 | 2717 | ||
| 1563 | 18년 전 | 2063 | ||
| 1562 | 18년 전 | 3047 | ||
| 1561 | 18년 전 | 10011 | ||
| 1560 |
행복속네잎크로버
|
18년 전 | 1909 | |
| 1559 | 18년 전 | 2825 | ||
| 1558 |
1111111
|
18년 전 | 2863 | |
| 1557 |
1111111
|
18년 전 | 2118 | |
| 1556 |
1111111
|
18년 전 | 2956 | |
| 1555 |
1111111
|
18년 전 | 3956 | |
| 1554 |
1111111
|
18년 전 | 2916 | |
| 1553 |
1111111
|
18년 전 | 2293 | |
| 1552 |
1111111
|
18년 전 | 6011 | |
| 1551 |
1111111
|
18년 전 | 3637 | |
| 1550 |
1111111
|
18년 전 | 6311 | |
| 1549 |
1111111
|
18년 전 | 2410 | |
| 1548 |
1111111
|
18년 전 | 2336 | |
| 1547 |
1111111
|
18년 전 | 2358 | |
| 1546 |
1111111
|
18년 전 | 3307 | |
| 1545 |
1111111
|
18년 전 | 3165 | |
| 1544 |
1111111
|
18년 전 | 1952 | |
| 1543 |
1111111
|
18년 전 | 3686 | |
| 1542 |
1111111
|
18년 전 | 1602 | |
| 1541 |
1111111
|
18년 전 | 1345 | |
| 1540 |
1111111
|
18년 전 | 1368 | |
| 1539 |
1111111
|
18년 전 | 1524 | |
| 1538 |
1111111
|
18년 전 | 1614 | |
| 1537 |
스카이부아
|
18년 전 | 3403 | |
| 1536 |
1111111
|
18년 전 | 2244 | |
| 1535 |
1111111
|
18년 전 | 1694 | |
| 1534 |
1111111
|
18년 전 | 2093 | |
| 1533 |
1111111
|
18년 전 | 4593 | |
| 1532 |
1111111
|
18년 전 | 2320 | |
| 1531 |
1111111
|
18년 전 | 2964 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기