本文整理汇总了Python中nntplib.NNTP.newnews方法的典型用法代码示例。如果您正苦于以下问题:Python NNTP.newnews方法的具体用法?Python NNTP.newnews怎么用?Python NNTP.newnews使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nntplib.NNTP
的用法示例。
在下文中一共展示了NNTP.newnews方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getItems
# 需要导入模块: from nntplib import NNTP [as 别名]
# 或者: from nntplib.NNTP import newnews [as 别名]
def getItems(self):
start = localtime(time()-self.window*day)
date = strftime('%y%m%d',start)
hour = strftime('%H%M%S',start)
server = NNTP(self.servername)
ids = server.newnews(self.group,date,hour)[1]
for id in ids:
lines = server.article(id)[3]
message = message_from_string('\n'.join(lines))
title = memssage['subject']
body = message.get_payload()
if message.is_multipart():
body = body[0]
yield NewsItem(title,body)
server.quit()
示例2: localtime
# 需要导入模块: from nntplib import NNTP [as 别名]
# 或者: from nntplib.NNTP import newnews [as 别名]
#coding=utf-8
#
from nntplib import NNTP
from time import strftime, time, localtime
day = 24 * 60 * 60 # Number of seconds in one day
yesterday = localtime(time() - day)
date = strftime('%y%m%d', yesterday)
hour = strftime('%H%M%S', yesterday)
servername = 'news.mixmin.net'
group = 'talk.euthanasia'
server = NNTP(servername)
ids = server.newnews(group, date, hour)[1]
for id in ids:
head = server.head(id)[3]
for line in head:
if line.lower().startswith('subject:'):
subject = line[9:]
break
body = server.body(id)[3]
print subject
print '-'*len(subject)
print '\n'.join(body)
server.quit()