Newsgroups
[1/2] from: ptretter:charter at: 3-Jul-2001 19:38
Can someone explain newsgroups and how to read the list from the server. I tried the
example in the core.pdf as such but got errors:
groups: read nntp://news.charter.net
Paul Tretter
[2/2] from: mario::cassani::icl::com at: 4-Jul-2001 9:21
Hi Paul,
> Can someone explain newsgroups and how to read the list from
> the server. I tried the example in the core.pdf as such but
> got errors:
>
> groups: read nntp://news.charter.net
>
Try this:
8<-----------8<-----------8<-----------8<-----------8<-----------
;News.r file
REBOL [
Title: "Newsgroups downloading script"
Author: "Mario Cassani"
EMail: [Mario--Cassani--icl--com]
Date: 09-04-2001
File: %News.r
Purpose: "Download the Newsgroups"
Category: '???
]
allgroups-file: %NewsgroupsRC.txt
allgroups: load allgroups-file
Newsgroupsdate: now/date
Newsgroupsyear: Newsgroupsdate/year
Newsgroupsmonth: Newsgroupsdate/month
if Newsgroupsmonth < 10 [Newsgroupsmonth: join "0" Newsgroupsmonth]
Newsgroupsday: Newsgroupsdate/day
if Newsgroupsday < 10 [Newsgroupsday: join "0" Newsgroupsday]
Newsgroupsdir: to-file join Newsgroupsyear ["/" Newsgroupsmonth "/"
Newsgroupsday]
daydir: func [givendate subdir][
datedir: to-file givendate
if not exists? datedir [
make-dir/deep datedir
]
if not none? subdir [
datedir: datedir: datedir/:subdir
if not exists? datedir [
make-dir datedir
]
]
]
daydir Newsgroupsdir "News"
catch
[
groupcount: 1
groupnumber: length? allgroups
while [groupcount <= groupnumber] [
groupURL: allgroups/:groupcount/2
groupservername: allgroups/:groupcount/1
daydir Newsgroupsdir/News groupservername
print join "Downloading from " groupservername
groupnames: allgroups/:groupcount/3
groupnamesnumb: length? groupnames
groupnamescount: 1
while [groupnamescount <= groupnamesnumb] [
TheGroup: groupnames/:groupnamescount
newsgroup: open groupURL/:TheGroup
length? newsgroup
;; TO-DO: Keep an index of the last read article from each
server/newsgroup and
;; select a specific message in the group by index, using pick:
; message: pick newsgroup index
; newsgroup: skip newsgroup index
print TheGroup
until [
write/append join Newsgroupsdir/News/:groupservername/:TheGroup
.txt
first newsgroup
newsgroup: next newsgroup
tail? newsgroup
]
groupnamescount: groupnamescount + 1
close newsgroup
]
groupcount: groupcount + 1
]
]
8<-----------8<-----------8<-----------8<-----------8<-----------
;NewsgroupsRC.txt file
[
["Charter" nntp://news.charter.net [alt.ascii-art rec.food.recipes]]
["ICL" news://news.cafevik.icl.co.uk/ [rec.food.drink.tea
rec.food.drink.coffee]]
]
8<-----------8<-----------8<-----------8<-----------8<-----------
Best regards
Mario