📄 newscheckgrp.py
字号:
import nntplib, StringIO, rfc822, sys
import time
def author(nn, h):
s = StringIO.StringIO("\r\n".join(h))
m = rfc822.Message(s)
sndr = m.getaddrlist("from")
return sndr[0][1]
SRVR = "east.usenetserver.com" # Your news server
USER ="sholden@usenetserver.com" # Your account name
PASS = "spdney11" # Your password
newsgroup = "comp.lang.python" # Group of your choice
nn = nntplib.NNTP(SRVR, user=USER, password=PASS)
nn.set_debuglevel(1)
resp, count, first, last, name = nn.group(newsgroup)
if count == '0':
print "No messages in ", newsgroup
sys.exit(-1)
resp, artlst = nn.newnews("comp.lang.python", "010405", "170000")
for a in artlst:
print a
nn.quit()
sys.exit(0)
while ct < 5:
sys.stdout.flush()
try:
a = author(nn, h)
if a == "sholden@holdenweb.com":
print "*** I wrote", n
else:
print a, "wrote", n
ct += 1
except nntplib.NNTPError:
pass
try:
n = nn.next()[1]
h = nn.head(n)[3]
except nntplib.NNTPError, resp:
if resp[:3] != '421':
break
print time.asctime(time.localtime(time.time())), ":", n
nn.quit()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -