Skip to content
컴퓨터잡담
2009.08.05 12:55

네이버, 다음지식 php로 RSS 출력 만들기

조회 수 31009 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄 첨부

네이버, 다음지식 php로 RSS 출력 만들기



RSS 수집을 하기위해 PHP로 RSS출력하는 소스를 만들어 보았습니다.


출력 내용은 제목, 링크주소, 태그 3개로 구성했습니다.


잘 나오는 것 같습니다.




 

 

 

 

<?


$a = file('http://kin.naver.com/open_home.php');

$bae = 0;

for($i=0;$i<count($a);$i++)
 {
 if(ereg('<div style="width:100%;">',$a[$i])) $cc = 1;
 if(ereg('<!-- //MAIN CONTENTS -->',$a[$i])) $cc = 0;

 if($cc == 1)
  {
  if(ereg('<td class="name"><a href="',$a[$i]))
    {
    $taga = explode('<td class="name"><a href="',$a[$i]);
    $taga = explode('</a>',$taga[1]);
    $tag[$bae] = $taga[0];
//    echo $tag[$bae];
    }
  if(ereg('<a href="/open100/db_detail.php?',$a[$i]))
    {
    $linka = explode('<a href="',$a[$i]);
    $linka = explode('" onMouseOver',$linka[1]);
    $link[$bae] = $linka[0];

    $titlea = explode(');">',$a[$i]);
    $titlea = explode('</a>',$titlea[1]);
    $title[$bae] = $titlea[0];

//    echo $link[$bae];
//    echo $title[$bae];

    $bae++;
    }
  }
 } //for_end

$content .= '<?xml version="1.0"?>'.chr(13);
$content .= '<rss version="2.0"><channel xmlns:psl="http://rainbow.daum.net/psl">'.chr(13);
$content .= '  <title>네이버지식 오픈사전</title>'.chr(13);
$content .= '  <link>http://kin.naver.com/open_home.php</link>'.chr(13);
$content .= '  <description>네이버지식 오픈사전</description>'.chr(13);
$content .= '  <pubDate></pubDate>'.chr(13);
$content .= '  <language>ko</language>'.chr(13);
$content .= '  <copyright>Copyright ⓒ NHN Corp. All Rights Reserved.</copyright>'.chr(13);
$content .= '  <webMaster>master@naver.com</webMaster>'.chr(13);
$content .= '  <generator>Naver</generator>'.chr(13);
$content .= '  <docs></docs>'.chr(13);
$content .= '  <ttl>20</ttl>'.chr(13);
$content .= '  <image>'.chr(13);
$content .= '  <url>http://static.naver.com/common/snb/090513/h_naver2.gif</url>'.chr(13);
$content .= '  <title>Naver RSS</title>'.chr(13);
$content .= '  <link>http://www.naver.com</link>'.chr(13);
$content .= '  </image>'.chr(13);

 

 

 

for($i=0;$i<count($title);$i++)
 {

  $content .= '  <item>'.chr(13);
  $content .= '  <title>'.$title[$i].'</title>'.chr(13);
  $content .= '  <link>http://kin.naver.com'.htmlspecialchars($link[$i]).'</link>'.chr(13);
  $content .= '  <description>'.$description.'</description>'.chr(13);
  $cate = explode(',',$tag[$i]);

  if($cate[0]) {$content .= ' <category>'.$cate[0].'</category>'.chr(13);}
  if($cate[1]) {$content .= ' <category>'.$cate[1].'</category>'.chr(13);}
  if($cate[2]) {$content .= ' <category>'.$cate[2].'</category>'.chr(13);}
  if($cate[3]) {$content .= ' <category>'.$cate[3].'</category>'.chr(13);}
  if($cate[4]) {$content .= ' <category>'.$cate[4].'</category>'.chr(13);}

//  for($ii=0;$ii<count($cate);$i++)
//   { echo '<category>'.$cate[$ii].'</category>'; }


  $content .= '</item>'.chr(13);
 }//for_end


$content .= '</channel>'.chr(13);
$content .= '</rss>'.chr(13);

 

?>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<?
$now=time();

$a = file('http://k.daum.net/qna/openknowledge/list.html?category_id=D');

$bae = 0;

for($i=0;$i<count($a);$i++)
 {
 if(ereg('<dl class="bList listTbar">',$a[$i])) $cc = 1;
 if(ereg('<!-- [openList] End -->',$a[$i])) $cc = 0;

 if($cc == 1)
  {
  if(ereg('class="bB12">',$a[$i]))
    {
    $taga = explode('class="bB12">',$a[$i]);
    $taga = explode('</a></dd>',$taga[1]);
    $tag[$bae] = $taga[0];
//    echo $tag[$bae];
    }
  if(ereg('<a href="/qna/openknowledge/view.html?',$a[$i]))
    {
    $linka = explode('<a href="',$a[$i]);
    $linka = explode('">',$linka[1]);
    $link[$bae] = $linka[0];

    $titlea = explode('">',$a[$i]);
    $titlea = explode('</a>',$titlea[1]);
    $title[$bae] = $titlea[0];

//    echo $link[$bae];
//    echo $title[$bae];

    $bae++;
    }
  }
 } //for_end

 

 

 

//header('Content-Type: text/xml; charset=euc-kr');

$content .= '<?xml version="1.0"?>'.chr(13);
$content .= '<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">'.chr(13);
$content .= '  <channel>'.chr(13);
$content .= ' <title>다음지식 오픈사전</title>'.chr(13);
$content .= ' <link>http://k.daum.net/qna/</link>'.chr(13);
$content .= ' <description>다음지식 오픈사전입니다.</description>'.chr(13);
$content .= ' <language>ko</language>'.chr(13);
$content .= ' <pubDate>'.date("D, d M Y H:i:s",$now).'</pubDate>'.chr(13);
$content .= ' <lastBuildDate>'.date("D, d M Y H:i:s",$now).'</lastBuildDate>'.chr(13); 
$content .= ' <generator>Urin79. Daum_openDIC_RSS</generator>'.chr(13);

 

for($i=0;$i<10;$i++)
 {

  $content .= ' <item>'.chr(13);

  $content .= '  <title>'.$title[$i].'</title>'.chr(13);
  $content .= '  <link>http://k.daum.net'.htmlspecialchars($link[$i]).'</link>'.chr(13);
  $content .= '  <description>'.$title[$i].'</description>'.chr(13);


  $cate = explode(',',$tag[$i]);

  if($cate[0]) {$content .= '  <category>'.$cate[0].'</category>'.chr(13);}
  if($cate[1]) {$content .= '  <category>'.$cate[1].'</category>'.chr(13);}
  if($cate[2]) {$content .= '  <category>'.$cate[2].'</category>'.chr(13);}
  if($cate[3]) {$content .= '  <category>'.$cate[3].'</category>'.chr(13);}
  if($cate[4]) {$content .= '  <category>'.$cate[4].'</category>'.chr(13);}

//  for($ii=0;$ii<count($cate);$i++)
//   { echo '<category>'.$cate[$ii].'</category>'; }


  $content .= ' </item>'.chr(13).chr(13);
 }//for_end

 

$content .= '</channel>'.chr(13);
$content .= '</rss>'.chr(13);


print $content;

// $file_pointer = fopen("../../temp/daum_man_rss.xml", "w");
//  $context = $content;
// fwrite($file_pointer, $context);
// fclose($file_pointer);


?>

 

 

 

로그인 후 댓글쓰기가 가능합니다.

?

  1. 19
    Sep 2009
    17:49

    [php] 특수문자 -> 엔티티, 엔티티 -> 특수문자

    Category컴퓨터잡담 Views19807
    Read More
  2. 21
    Sep 2009
    10:49

    한글프로그램 메뉴-모양-세로쓰기

    Category컴퓨터잡담 Views15752
    Read More
  3. 23
    Sep 2009
    08:27

    사이트 디자인 무료 템플릿 공유

    Category컴퓨터잡담 Views22758
    Read More
  4. 01
    Oct 2009
    13:18

    오토런 바이러스

    Category컴퓨터잡담 Views11369
    Read More
  5. 17
    Oct 2009
    08:16

    PHP로 그림에 글자 입히기

    Category컴퓨터잡담 Views19996
    Read More
  6. 17
    Oct 2009
    08:20

    php로 이미지를 mysql디비 저장하고 보여주는 소스

    Category컴퓨터잡담 Views62317
    Read More
  7. 17
    Oct 2009
    08:38

    php 이미지 저장 및 이미지크기를 줄여 저장기술 소스

    Category컴퓨터잡담 Views14232
    Read More
  8. 20
    Oct 2009
    08:35

    PHP로 FTP 접속 / 업로드 / 다운로드 등의 컨트롤 소스

    Category컴퓨터잡담 Views32766
    Read More
  9. 27
    Oct 2009
    08:49

    jQuery 강좌

    Category컴퓨터잡담 Views12630
    Read More
  10. 13
    Nov 2009
    17:43

    MYSQL 최적화

    Category컴퓨터잡담 Views22447
    Read More
  11. 17
    Nov 2009
    09:15

    많은 DB 요청시 자동으로 막히는 현상 해제

    Category컴퓨터잡담 Views22924
    Read More
  12. 19
    Nov 2009
    08:35

    mysql 재시작, 사용자 추가 명령어

    Category컴퓨터잡담 Views32229
    Read More
  13. 19
    Nov 2009
    09:55

    bat(배치)파일 문법

    Category컴퓨터잡담 Views13294
    Read More
  14. 19
    Nov 2009
    09:55

    bat(배치)파일 문법

    Category컴퓨터잡담 Views12459
    Read More
  15. 19
    Nov 2009
    10:21

    mysqladmin

    Category컴퓨터잡담 Views14065
    Read More
  16. 20
    Nov 2009
    08:18

    서버 해킹 당하다~

    Category컴퓨터잡담 Views15662
    Read More
  17. 21
    Nov 2009
    12:27

    MYSQL 미 해결 과제 : Can't connect to MySQL server on 'localhost'(10055)

    Category컴퓨터잡담 Views64229
    Read More
  18. 24
    Nov 2009
    00:44

    bat(배치) 파일 제대로 쓰기

    Category컴퓨터잡담 Views6874
    Read More
  19. 24
    Nov 2009
    08:51

    Ghost용 배치 파일 작성 예

    Category컴퓨터잡담 Views8162
    Read More
  20. 24
    Nov 2009
    09:39

    Windows 초간단 remote 백업 명령

    Category컴퓨터잡담 Views23511
    Read More
Board Pagination Prev 1 2 3 4 5 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소