> Ryan, if your server supports it, you could use nntp.r's xhdr
> feature to get the date headers from a newsgroup, determine which
> articles are new (greater than your start date) and download those.
I have been working on a script which will retrieve newsgroup news and then output only a single day (the previous day) to an HTML file so that I can post the messages on a web page. If I grab more than one day's worth of messages, the web page becomes too large (as much as 1MB.)
Unfortunately, REBOL does not understand the date formats. There are at least three date formats used by newsgroups, as follows:
Date: Tue, 22 Feb 2000 15:33:09 GMT
Date: Tue, 22 Feb 2000 16:49:03 +0100
Date: 22 Feb 2000 16:00:52 GMT
At first, I thought newsgroups only used the top two date formats, meaning I could find the messages I want based on the day of the week.
REBOL []
foreach fields next read/lines %BeAdvocacyMessages.txt [
messages: set to-word rejoin ["message" count] {}
foreach word parse fields none [append words word]
firstword: pick words 1
secondword: pick words 2
either firstword = "Date:" [
today: now/weekday
monday: make integer! 1
tuesday: make integer! 2
wednesday: make integer! 3
thursday: make integer! 4
friday: make integer! 5
saturday: make integer! 6
sunday: make integer! 7
if secondword = "Mon" [dateday: monday]
if secondword = "Tue" [dateday: tuesday]
if secondword = "Wed" [dateday: wednesday]
if secondword = "Thu" [dateday: thursday]
if secondword = "Fri" [dateday: friday]
if secondword = "Sat" [dateday: saturday]
if secondword = "Sun" [dateday: sunday]
daymath: today - dateday
if daymath < -6 [clearmessage: true]
switch daymath [
-6 [clear fields clear messages]
-5 [clearmessage: true]
-4 [clearmessage: true]
-3 [clearmessage: true]
-4 [clearmessage: true]
-3 [clearmessage: true]
-2 [clearmessage: true]
-1 [clearmessage: true]
0 [clearmessage: true]
1 [clear fields clear messages]
]
][append ignore fields]
]
But then I discovered, of course, that news servers also have "Date:" headers as follows:
Date: 22 Feb 2000 16:00:52 GMT
I was hoping I could make things simpler by downloading only the messages I wanted from the news server, but I guess it's not going to work that way.
-ryan
