[FLUG] Python newsreader 2

  • From: Lorenzo Bolognini <lorenzo@xxxxxxxxxxxxx>
  • To: fanolug <fanolug@xxxxxxxxxxxxx>
  • Date: Sat, 22 Feb 2003 23:26:37 +0100

Mailing List del Fortunae LUG
=============================

Mi è partito, non volendo, il messaggio incompleto... eccovi il codice.

Ciao,
Lo

#alpha cgi-newsr v.0.0
#description: web-based newsreader
#author: lorenzo bolognini
#email: lorenzo at bolognini dot net
#####################################
from nntplib import *
print"""
-----------------------------------
cgi-newsr - by lorenzo bolognini
email: lorenzo at bolognini dot net
-----------------------------------"""

#create a new NNTP object
cnn = NNTP('powernews.libero.it')

#just useful
cnn.set_debuglevel(1)

#get echo from server
cnn.getwelcome()

#set group
mygrp = cnn.group('comp.lang.python')

#grab first and last msg number on group
#and prints some infos
last = int(mygrp[3])
first = int(mygrp[2])
count = mygrp[1]
print "Last msg n.: %s" % last
print "First msg n.: %s" % first
print "Msg count: %s" % count

#number of articles to retrieve
nret = 10

#calculate the first article to be retrieved
new_first = str(last - 10)
new_news = cnn.xover(new_first, mygrp[3])

print """
--------------------
Printing msg headers
--------------------"""

msg_info = new_news[1]
for i in range(len(msg_info)):
    print "----.n. %d ----" % i
    print msg_info[i]
    print "\n"

cnn.quit()

--
Nobody said it was easy...
-- Coldplay

--
Bill Gates : "No! Nel nostro software non ci sono bug significativi che un numero 
significativo di utenti vuol vedere corretti."

Other related posts:

  • » [FLUG] Python newsreader 2