本文整理汇总了Python中reddit.Reddit.post方法的典型用法代码示例。如果您正苦于以下问题:Python Reddit.post方法的具体用法?Python Reddit.post怎么用?Python Reddit.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reddit.Reddit
的用法示例。
在下文中一共展示了Reddit.post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from reddit import Reddit [as 别名]
# 或者: from reddit.Reddit import post [as 别名]
def main(subreddit):
print "Subreddit :", subreddit
rsub = url_data("http://www.reddit.com/r/%s/new/.json?sort=new"%subreddit, json=True)
children = rsub['data']['children']
r = Reddit(USERNAME, PASSWORD)
session = r.login()
f = open('history.txt', 'r')
history = f.read()
f.close()
for child in children:
is_self = child['data']['is_self']
thread_id = child['data']['name']
print thread_id
if thread_id in history:
print "Thread: %s already in history"%thread_id
pass
else:
if not is_self:
img_url = child['data']['url']
thread_id = child['data']['name']
repost = karmadecay(img_url)
if repost:
text = form_comment(repost)
r_resp = r.post(session, thread_id, text)
if r_resp != None:
error = r_resp['json']['errors']
delay = find_digit(error[0][1])
print "waiting: %s seconds" %delay*60
time.sleep(delay*60)
r.post(session, thread_id, text)
f = open('history.txt', 'a')
f.write("\n%s"%thread_id)
print text
f.close()
time.sleep(1)
print "Comment Posted:", thread_id
else:
pass
else:
pass
print "Finished"
return