saving NNTP bodies to disk
Daniel.Kinnaer at AdValvas.be
Wed Dec 27 00:20:43 CET 2000
Hello. I've come up with a small Python script but ran into trouble.
Here's what I'm trying to do : get a NNTP connection, get the last 10
headers AND bodies and save them to disk. It seems I made an error: I
try to write a list to disk using f.write() and Python complains about
this with following report
TypeError: read-only character buffer, list
Below is the script. Can someone please explain me what I'm doing
wrong? All help is greatly appreciated. Thanks
print "Start script..."
from nntplib import *
print "### Ok! Starting to read from Skynet..."
resp, count, first,last,name = s.group('comp.lang.python')
print 'Group', name, 'has', count, 'articles, range', first, 'to',
resp, subs = s.xhdr('subject', first + '-' + last)
print "showing and saving only last 10 headers + bodies..."
for id, sub in subs[-10:]:
print id, sub
#save body to disk
f=open( id,'w') #how do I add an extension 'txt' ???
for i in range(0,len(TheBody)):
print i,TheBody[i] #show on screen
print "End of Script..."
More information about the Python-list