웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
올블로그(http://www.allblog.net/Home/) 명예의 전당글 가져오기
2006.04.17 16:31
http://www.allblog.net/Home/http://search.dyd.cc/simplereader.php요새 rss 주소만 알면 글들을 쉽게 내 홈페이지에 달수 있습니다.
rss 를 읽어오는데 꼭 rss reader 처럼 포괄적인것으로 읽어올 필요는 없습니다.
rss도 버젼이 다양하고, 보여주는 쪽에서 규칙외에 부분으로 보여주는 경우도 있기 때문에
기존 rss reader 들이 덩어리가 커지고 그렇습니다.
단순히 현재의 rss의 정보를 읽어서 그것을 적당히 보여주는 것이 목적이라면
다음과 같이 하여도 됩니다.
보여주는 모양새는 한rss ( http://www.hanrss.com/ )를 참조햇습니다.
--------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rss 읽어오기</title>
<style>
body {margin:0px 10px 3px 10px;padding:0}
body,td,select {font-family:Verdana,Gulim;font-size:9pt;}
td {overflow:hidden;text-overflow:ellipsis;}
td.description p {margin:0;padding:3 0 3 0;}
a.lnk1:link,a.lnk1:visited,a.lnk1:hover {color:#0000ff;text-decoration:underline;}
a.lnk2:link,a.lnk2:visited {color:#808080;text-decoration:none;}
a.lnk2:hover {text-decoration:underline;}
a.lnk3:link {color:#0000ff;text-decoration:none;}
a.lnk3:visited {color:#800080;text-decoration:none;}
a.lnk3:hover {text-decoration:underline;}
a.lnk4:link,a.lnk4:visited {color:#D2691E;text-decoration:none;}
a.lnk4:hover {text-decoration:underline;}
a.lnk5:link,a.lnk5:visited {color:#0000ff;text-decoration:none;}
a.lnk5:hover {background-color:#eeeeee;}
.header1 {font-weight:bold;font-size:12pt;}
.btn_submit1 {border:1px solid gray;width:40;height:20;background-color:white;font-family:Gulim;font-size:9pt;padding:2 0 0 0}
.btn_submit2 {border:1px solid #c0c0c0;width:34;height:18;background-color:white;font-family:Gulim;font-size:8pt;line-height:12pt}
</style>
<base target=_blank>
</head>
<body bgcolor='#ffffff'>
<?php
//올블로그 명예의전당 rss 글내용이 하루에 한번만 바뀝니다.
$url = "http://www.allblog.net/Rss/BestPosts.xml";
$result = file($url);
$text = implode("n", $result);
if(!empty($text)){
$item = explode("<item>", $text);
$count = count($item);
echo "
<table width=100% border=0 cellpadding=0 cellspacing=0 style="table-layout:fixed;">
<tr><td>
<table width=100% border=0 cellpadding=0 cellspacing=0 style="table-layout:fixed;">
<tr>
<td align=right valign=top style="padding:0 4 0 0;font-size:8pt;color:gray" nowrap>총 <b>" . ($count - 1) . "</b>개 | 최종업데이트: " . date("Y-m-d H:i") . "</td>
</tr>
</table>
</td></tr>
<tr><td height=4></td></tr>
</table>
";
if (is_array($item) && count($item) > 1) {
for ($i = 1; $i < $count; $i++){
preg_match_all("`<title>(.+)</title><link>(.+)</link><source url=".+">(.+)</source><category>([^<]+)</category>(<category>([^<]+)</category>)?(<category />)?<pubDate>(.+)</pubDate><description><![CDATA[(.+)]]></description>`s", $item[$i], $matches);
if (is_array($matches[1]) && count($matches[1]) > 0) {
foreach($matches[1] as $key => $val){
$title = (!empty($val)) ? $val : '';
$link = (!empty($matches[2][$key])) ? $matches[2][$key] : '';
$source = (!empty($matches[3][$key])) ? $matches[3][$key] : '';
$category1 = (!empty($matches[4][$key])) ? $matches[4][$key] : '';
$category2 = (!empty($matches[6][$key])) ? $matches[6][$key] : '';
$category = (!empty($category1) && !empty($category2)) ? $category1 . ", " . $category2 : $category1 . $category2;
$pubDate = (!empty($matches[8][$key])) ? date("Y-m-d H:i", strtotime($matches[8][$key])) : '';
$description = (!empty($matches[9][$key])) ? $matches[9][$key] : '';
$description_len = number_format(strlen($description));
if (!preg_match("`(<s*t*imgs*t*|<s*t*as*t*href)`i", $description)) $description = strip_tags(str_replace(array("<", ">", "<br /><hr />위 내용은 올블로그가 올블로그에 등록한 블로그로부터 수집하여 서버에 저장하고 있는 내용의 전체 또는 일부 입니다. 이 게시물에 대한 모든 저작권과 책임은 해당 블로그의 등록자에게 있습니다."), array("<", ">", ""), $description)) . "<br /><hr />위 내용은 올블로그가 올블로그에 등록한 블로그로부터 수집하여 서버에 저장하고 있는 내용의 전체 또는 일부 입니다. 이 게시물에 대한 모든 저작권과 책임은 해당 블로그의 등록자에게 있습니다.";
echo "
<a href="" . $link . ""></a>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td bgcolor=#bdb76b><img width=1 height=1 alt=""></td></tr>
<tr><td bgcolor=#ebebd5 style='padding:5 2 6 2'>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style="font-size:10pt"><a href="" . $link . ""><span style="font-weight:bold">" . $title . "</span></a></td></tr>
</table>
</td></tr>
<tr><td style='padding:4 2 0 2'>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style='font-size:8pt;'> <font color=#808080>" . $pubDate . " 작성 <font color=#808080>| " . $category . "</font> <font color=#808080>| " . $description_len . "byte</font></font></td><td align=right style="font-family:Gulim;font-size:8pt;" nowrap> </td></tr>
</table>
</td></tr>
</table>
<table id="desc_9612007" width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style='padding:6 2 0 2;line-height:14pt;' class=description>" . $description . "</td></tr>
<tr><td height=10></td></tr>
</table>
<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td height=12></td></tr></table>
";
}
}
}
}
}
?>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------------
여기에 캐쉬기능만 달면 올블로그 전용으로는 가벼운 리더기가 될수 있습니다.
참고 url http://search.dyd.cc/simplereader.php
위의 내용을 utf-8로 저장하여야 에러가 없습니다
rss 를 읽어오는데 꼭 rss reader 처럼 포괄적인것으로 읽어올 필요는 없습니다.
rss도 버젼이 다양하고, 보여주는 쪽에서 규칙외에 부분으로 보여주는 경우도 있기 때문에
기존 rss reader 들이 덩어리가 커지고 그렇습니다.
단순히 현재의 rss의 정보를 읽어서 그것을 적당히 보여주는 것이 목적이라면
다음과 같이 하여도 됩니다.
보여주는 모양새는 한rss ( http://www.hanrss.com/ )를 참조햇습니다.
--------------------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Rss 읽어오기</title>
<style>
body {margin:0px 10px 3px 10px;padding:0}
body,td,select {font-family:Verdana,Gulim;font-size:9pt;}
td {overflow:hidden;text-overflow:ellipsis;}
td.description p {margin:0;padding:3 0 3 0;}
a.lnk1:link,a.lnk1:visited,a.lnk1:hover {color:#0000ff;text-decoration:underline;}
a.lnk2:link,a.lnk2:visited {color:#808080;text-decoration:none;}
a.lnk2:hover {text-decoration:underline;}
a.lnk3:link {color:#0000ff;text-decoration:none;}
a.lnk3:visited {color:#800080;text-decoration:none;}
a.lnk3:hover {text-decoration:underline;}
a.lnk4:link,a.lnk4:visited {color:#D2691E;text-decoration:none;}
a.lnk4:hover {text-decoration:underline;}
a.lnk5:link,a.lnk5:visited {color:#0000ff;text-decoration:none;}
a.lnk5:hover {background-color:#eeeeee;}
.header1 {font-weight:bold;font-size:12pt;}
.btn_submit1 {border:1px solid gray;width:40;height:20;background-color:white;font-family:Gulim;font-size:9pt;padding:2 0 0 0}
.btn_submit2 {border:1px solid #c0c0c0;width:34;height:18;background-color:white;font-family:Gulim;font-size:8pt;line-height:12pt}
</style>
<base target=_blank>
</head>
<body bgcolor='#ffffff'>
<?php
//올블로그 명예의전당 rss 글내용이 하루에 한번만 바뀝니다.
$url = "http://www.allblog.net/Rss/BestPosts.xml";
$result = file($url);
$text = implode("n", $result);
if(!empty($text)){
$item = explode("<item>", $text);
$count = count($item);
echo "
<table width=100% border=0 cellpadding=0 cellspacing=0 style="table-layout:fixed;">
<tr><td>
<table width=100% border=0 cellpadding=0 cellspacing=0 style="table-layout:fixed;">
<tr>
<td align=right valign=top style="padding:0 4 0 0;font-size:8pt;color:gray" nowrap>총 <b>" . ($count - 1) . "</b>개 | 최종업데이트: " . date("Y-m-d H:i") . "</td>
</tr>
</table>
</td></tr>
<tr><td height=4></td></tr>
</table>
";
if (is_array($item) && count($item) > 1) {
for ($i = 1; $i < $count; $i++){
preg_match_all("`<title>(.+)</title><link>(.+)</link><source url=".+">(.+)</source><category>([^<]+)</category>(<category>([^<]+)</category>)?(<category />)?<pubDate>(.+)</pubDate><description><![CDATA[(.+)]]></description>`s", $item[$i], $matches);
if (is_array($matches[1]) && count($matches[1]) > 0) {
foreach($matches[1] as $key => $val){
$title = (!empty($val)) ? $val : '';
$link = (!empty($matches[2][$key])) ? $matches[2][$key] : '';
$source = (!empty($matches[3][$key])) ? $matches[3][$key] : '';
$category1 = (!empty($matches[4][$key])) ? $matches[4][$key] : '';
$category2 = (!empty($matches[6][$key])) ? $matches[6][$key] : '';
$category = (!empty($category1) && !empty($category2)) ? $category1 . ", " . $category2 : $category1 . $category2;
$pubDate = (!empty($matches[8][$key])) ? date("Y-m-d H:i", strtotime($matches[8][$key])) : '';
$description = (!empty($matches[9][$key])) ? $matches[9][$key] : '';
$description_len = number_format(strlen($description));
if (!preg_match("`(<s*t*imgs*t*|<s*t*as*t*href)`i", $description)) $description = strip_tags(str_replace(array("<", ">", "<br /><hr />위 내용은 올블로그가 올블로그에 등록한 블로그로부터 수집하여 서버에 저장하고 있는 내용의 전체 또는 일부 입니다. 이 게시물에 대한 모든 저작권과 책임은 해당 블로그의 등록자에게 있습니다."), array("<", ">", ""), $description)) . "<br /><hr />위 내용은 올블로그가 올블로그에 등록한 블로그로부터 수집하여 서버에 저장하고 있는 내용의 전체 또는 일부 입니다. 이 게시물에 대한 모든 저작권과 책임은 해당 블로그의 등록자에게 있습니다.";
echo "
<a href="" . $link . ""></a>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td bgcolor=#bdb76b><img width=1 height=1 alt=""></td></tr>
<tr><td bgcolor=#ebebd5 style='padding:5 2 6 2'>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style="font-size:10pt"><a href="" . $link . ""><span style="font-weight:bold">" . $title . "</span></a></td></tr>
</table>
</td></tr>
<tr><td style='padding:4 2 0 2'>
<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style='font-size:8pt;'> <font color=#808080>" . $pubDate . " 작성 <font color=#808080>| " . $category . "</font> <font color=#808080>| " . $description_len . "byte</font></font></td><td align=right style="font-family:Gulim;font-size:8pt;" nowrap> </td></tr>
</table>
</td></tr>
</table>
<table id="desc_9612007" width=100% border=0 cellpadding=0 cellspacing=0>
<tr><td style='padding:6 2 0 2;line-height:14pt;' class=description>" . $description . "</td></tr>
<tr><td height=10></td></tr>
</table>
<table width=100% border=0 cellpadding=0 cellspacing=0><tr><td height=12></td></tr></table>
";
}
}
}
}
}
?>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------------------
여기에 캐쉬기능만 달면 올블로그 전용으로는 가벼운 리더기가 될수 있습니다.
참고 url http://search.dyd.cc/simplereader.php
위의 내용을 utf-8로 저장하여야 에러가 없습니다
댓글 2
-
허므
2006.04.22 23:27
-
유창화
2006.04.23 11:38
fopen 함수가 지원되어야만 사용가능한 팁입니다.
파일은 utf-8로 저장하십시오.
제목 | 글쓴이 | 날짜 |
---|---|---|
플래시 칼라피커 두번째 버전 [1] | 행복한고니 | 2005.03.16 |
플래쉬 갤러리 비슷한 자바스크립 갤러리 [13] | monozzang | 2005.04.04 |
풍선도움말 스크립트 [3] | 행복한고니 | 2005.04.11 |
타켓으로 페이지 이동하는 스크립트 [2] | 로크 | 2005.04.16 |
팝업창을 내용에 맞게 크기 자동조정하기 [2] | 김경수 | 2005.04.23 |
상태 표시줄 감지 (URL 가리고 내용 표시) 업그레이드 소스 [2] | ArⓒH | 2005.05.30 |
링크 점선 처리 onfocus=blur() [5] | woosh | 2005.06.06 |
마우스 오른쪽버튼 금지시키기스크립트 [5] | 박시현 | 2005.06.26 |
파일 업로드 버튼 이미지로 사용하기 [1] | 행복한고니 | 2005.06.29 |
SP2 팝업차단 무시하고 팝업띠우기?! [8] | 오길호 | 2005.07.23 |
미디어 플레이어? 난 곰플레이어야! [9] | 송재영 | 2005.07.24 |
자바스크립트 음악목록 랜덤 재생하기 | 만능천사 | 2005.08.14 |
Rain# 머문시간 나타내기 [상태창] | Rain | 2005.08.14 |
뉴스티커 [4] | beMax | 2005.08.26 |
배경색 랜덤으로 바꾸는 스크립트 [1] | ColonD | 2005.10.15 |
클릭으로 배경색 바꾸는 스크립트(수정) [1] | ColonD | 2005.10.16 |
2005/10/16 21:15 pm 형식으로 출력되는 시계 [5] | 웹-하루 | 2005.10.18 |
임의로 전체에서 몇개의 배너만 출력하기(오류 수정 ㅜ,.ㅜ) | ColonD | 2005.10.20 |
주소창에 경로감추기 [5] | ☆쭈야☆ | 2005.10.29 |
홈페이지 만드실때 방문자의 해상도가 걱정 되신다면 [5] | 한용 | 2005.11.11 |
전 에러 뜨는데..
foen()