3초기억력

ASP - 구글 뉴스 RSS 퍼오기 (카테고리별) 본문

플밍_ASP

ASP - 구글 뉴스 RSS 퍼오기 (카테고리별)

잠수콩 2011. 8. 4. 13:14

제목 :  구글 뉴스 RSS 퍼오기



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
<%
 topic = request("topic")
 url = "http://news.google.com/news?pz=1&jfkl=true&cf=all&ned=kr&hl=ko&topic="&topic&"&output=rss"
    nodeName = "item"
    objName = "rss"
    call getXML(url, nodeName, objName)   
%>
        <span id="mw-today" class="today"></span>
        <script language="javascript">
          function showTitleNowTime(){
            var today = new Date();
            var hour  = today.getHours();
            var minute= today.getMinutes();
            var second= today.getSeconds();
            var dayNm = '<%=year(now)%>년 <%=month(now)%>월 <%=day(now)%>일 <%=weekdayname(weekday(now))%>';
       
            if(minute<10){minute='0'+minute;}
            if(second<10){second='0'+second;}
       
            var viewDaytime = '<font color=blue>'+dayNm +' '+hour+':'+minute+':'+second+'</font>';
            document.getElementById("mw-today").innerHTML=viewDaytime;
            setTimeout('showTitleNowTime()',1000);
          }
        showTitleNowTime();
        </script>
<table width="100%" border="0">
 <tr>
  <td><a href="?topic=">주요뉴스</a> | <a href="?topic=p">정치</a> | <a href="?topic=b">경제</a> | <a href="?topic=y">사회</a> | <a href="?topic=l">문화/생활</a> | <a href="?topic=w">국제</a> | <a href="?topic=t">정보과학</a> | <a href="?topic=e">연예</a> | <a href="?topic=s">스포츠</a> | <a href="?topic=po">인기뉴스</a></td>
 </tr>
<%   
 i = 1
    for each SubNodes in rss
     title = SubNodes.getElementsByTagName("title")(0).Text
     link = SubNodes.getElementsByTagName("link")(0).Text
     'pubDate = SubNodes.getElementsByTagName("pubDate")(0).Text
     'description = SubNodes.getElementsByTagName("description")(0).Text
    
%>
<tr>
    <td><a href="<%=link%>" target="_blank"><%=i%>. <%=title%></a></td>
</tr>
<%      
 If i = 10 Then Exit For
 i = i + 1
    next   
%>
</table>
</body>
</html>
<%
   Sub getXML(URL, nodeName, varName)
         Set xmlHTTP = Server.CreateObject("Microsoft.XMLHTTP")
         xmlHTTP.Open "GET", URL, false
         xmlHTTP.SetRequestHeader "Content-type", "text/xml"
         xmlHTTP.Send
         strXML = xmlHTTP.ResponseText
         Set xmlHTTP = Nothing

         Set xmlObj = Server.CreateObject("Microsoft.XMLDOM")
         xmlObj.async = False
         xmlObj.loadXML(strXML)
        
         Set objRoot = xmlObj.documentElement
         Set xmlObj = Nothing

         Execute "Set " & varName & " = objRoot.selectNodes(""//" & nodeName & """)"
         Set objRoot = Nothing
    End Sub
%>

 

내용 :  news.google.co.kr 의 한국 뉴스를 rss에서 퍼오기

출처 : 자체제작
Comments