本文整理汇总了Python中Actions.remove_post方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.remove_post方法的具体用法?Python Actions.remove_post怎么用?Python Actions.remove_post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actions
的用法示例。
在下文中一共展示了Actions.remove_post方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clear_sub
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import remove_post [as 别名]
def clear_sub(credentials, sub, num=20):
"""Removes all* old posts from a sub (use with care)
* up to 900
:param credentials:
:param sub:
:return:
"""
num = min(num, 900)
if num < 0:
num = int(1e6)
mypraw = create_multiprocess_praw(credentials)
sub = get_subreddit(credentials, mypraw, sub)
old_stream = p.helpers.submission_stream(mypraw, sub, limit=num)
results = []
try:
#delete all old posts
for i in range(num):
try:
post = old_stream.next()
Actions.remove_post(post, delete=True)
print("# {} deleted...".format(i))
except AttributeError:
# Post or Comment may have been deleted between retrieving it
# and accessing its fields
pass
except AssertionError, e:
logging.log(logging.DEBUG, str(e) + "\nNo Posts!")
示例2: main
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import remove_post [as 别名]
def main():
from CredentialsImport import CRImport
import utilitymethods as u
import logging
testbed = None
saved_posts = {}
# mark true if the script should remove all old posts from the testbed
DELETE_OLD = True
#import credentials
credentials = CRImport("TestCredentials.cred")
#create my reddit
r = u.create_multiprocess_praw(credentials)
#get testbed sub
testbed = u.get_subreddit(credentials, r)
#create datasource object
datasource = u.get_subreddit(credentials, r, credentials["DATAMININGSUB"])
if DELETE_OLD:
old_stream = praw.helpers.submission_stream(r, testbed, limit=POST_LIMIT)
results = []
try:
#delete all old posts
for post in old_stream:
try:
Actions.remove_post(post, delete=True)
print("deleted old post: %s..." % post.title[:20])
except AttributeError:
# Post or Comment may have been deleted between retrieving it
# and accessing its fields
pass
except AssertionError, e:
logging.log(logging.DEBUG, str(e) + "\nNo Posts!")
示例3: testRemovePost
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import remove_post [as 别名]
def testRemovePost(sub, post):
# spawn a Removal action
print "Remove Post:"
val = a.remove_post(post)
print "Passed" if val else "Failed"
return val
示例4: remove_and_post
# 需要导入模块: import Actions [as 别名]
# 或者: from Actions import remove_post [as 别名]
def remove_and_post(self, post, comment):
Actions.remove_post(self, post)
Actions.make_comment(post, comment, dist=True)