Personal tools
Document Actions

Getting Articles from RSS Feed

by Days posted at 2007-01-11 23:19 last modified 2007-01-11 23:19
必要に迫られて、RSSフィードから特定の項目だけを抜き出してWebに表示するASPプログラムを作った。
AJAX使えばサーバサイドで動かす必要はないし、これよりも簡単にできるのだけれど、今回本当はWSHで動かしたかったり、DBへのレコード挿入をしたかったりしたので、VBSで書いてみた。
更新日時を抜き出すstrdateとstrtimeのところは、RFC822に準拠していれば、これで足りるはず。他がどこまで汎用的なのかわからないけれど。
Dim strURL, objHTTP, strRetVal
Dim objDOM, rtResult, objNd

' original feed URI
strURL = "http://www.mobileplace.org/dias/blog/RSS"

' Get data from feed
Set objHTTP = server.CreateObject("MSXML2.XMLHTTP")
	objHTTP.Open "GET", strURL, False
	objHTTP.Send
	strRetVal = objHTTP.responseText
Set objHTTP = Nothing


Set objDOM = Server.CreateObject("MSXML2.DOMDocument")
	rtResult = objDOM.loadXML(strRetVal)
If rtResult = True Then
	set objNd = objDOM.documentElement.selectNodes("/rdf:RDF/item")
	for i = 0 to objNd.length-1
		strtitle = objNd(i).selectSingleNode("title").text
		strlink = objNd(i).selectSingleNode("link").text
		strdcdate = objNd(i).selectSingleNode("dc:date").text
		strdate = mid(strdcdate, 1, 10)
		strtime = mid(strdcdate, 12, 5)
		strdescription = objNd(i).selectSingleNode("description").text

		' Output articles
		response.write strtitle & "
" response.write strlink & "
" response.write strdate & " " & strtime & "
" response.write strdescription & "
" Next End If Set objDOM = Nothing
Category(s):
仕事の周辺
The URL to Trackback this entry is:
http://www.mobileplace.org/dias/blog/getting-articles-from-rss-feed/tbping
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)
(Required)

« February 2012 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29