コード例 #1
0
		exit(1)
	# Save cookies so we won't have to log in again later
	reddit.save_cookies('cookies.txt')

print('logged in as %s' % reddit.user)

uinfo = reddit.user_info()
print('\nlink karma:    %d' % uinfo.link_karma)
print('comment karma: %d' % uinfo.comment_karma)
	

# Retrieve posts in a subreddit
posts = reddit.get('/r/%s' % MOD_SUB)
print('posts in subreddit /r/%s:' % MOD_SUB)
for post in posts:
	if(post.clicked is False):
		reddit.fetch_comments(post)
		for comment in post.comments:
			words = re.split("\?|\ |,|!|\n",comment.body)
			for word in words:
				if "http://www.tobaccoreviews.com" in word:
					linkURL = word
					if "/blend/" in word:
						webtry = urllib2.urlopen(word)
						html = webtry.read()
						parser = MyHTMLParser()
						parser.feed(html)
						replyMessage = "["+tobaccoName+"]("+word+")"+"\n\n"
						reddit.reply(comment,replyMessage)
		post.clicked = True
コード例 #2
0
        print('remember to change USERNAME and PASSWORD')
        exit(1)
    # Save cookies so we won't have to log in again later
    reddit.save_cookies('cookies.txt')

print('logged in as %s' % reddit.user)

uinfo = reddit.user_info()
print('\nlink karma:    %d' % uinfo.link_karma)
print('comment karma: %d' % uinfo.comment_karma)

# Retrieve posts in a subreddit
posts = reddit.get('/r/%s' % MOD_SUB)
print('posts in subreddit /r/%s:' % MOD_SUB)
for post in posts:
    if (post.clicked is False):
        reddit.fetch_comments(post)
        for comment in post.comments:
            words = re.split("\?|\ |,|!|\n", comment.body)
            for word in words:
                if "http://www.tobaccoreviews.com" in word:
                    linkURL = word
                    if "/blend/" in word:
                        webtry = urllib2.urlopen(word)
                        html = webtry.read()
                        parser = MyHTMLParser()
                        parser.feed(html)
                        replyMessage = "[" + tobaccoName + "](" + word + ")" + "\n\n"
                        reddit.reply(comment, replyMessage)
        post.clicked = True
コード例 #3
0
ファイル: ReddiTest.py プロジェクト: eliawry/socialcascades
	print('\t%s: "%s"' % (comment.author, comment.body[:60].replace('\n',' ')))

# Store first comment for other functions
if len(post.comments) > 0:
	comment = post.comments[0]

# Upvote post
reddit.upvote(post)
# Upvote comment
reddit.upvote(comment)
# Save post
reddit.save(post)

# Reply to post
print('replying to post "%s"' % (post.title))
result = reddit.reply(post, "I can't believe this is in /r/%s" % post.subreddit)
if result == {}:
	print('unable to reply to post')
else:
	print('replied to %s, %s' % (result['parent'], result['id']))

# Reply to comment
print('replying to comment by %s' % (comment.author))
result = reddit.reply(comment, "I like the part where you said:\n\n>%s" % comment.body.replace('\n\n', '\n\n>'))
if result == {}:
	print('unable to reply to post')
else:
	print('replied to %s, %s' % (result['parent'], result['id']))


# Testing submitting link
コード例 #4
0
          (comment.author, comment.body[:60].replace('\n', ' ')))

# Store first comment for other functions
if len(post.comments) > 0:
    comment = post.comments[0]

# Upvote post
reddit.upvote(post)
# Upvote comment
reddit.upvote(comment)
# Save post
reddit.save(post)

# Reply to post
print('replying to post "%s"' % (post.title))
result = reddit.reply(post,
                      "I can't believe this is in /r/%s" % post.subreddit)
if result == {}:
    print('unable to reply to post')
else:
    print('replied to %s, %s' % (result['parent'], result['id']))

# Reply to comment
print('replying to comment by %s' % (comment.author))
result = reddit.reply(
    comment, "I like the part where you said:\n\n>%s" %
    comment.body.replace('\n\n', '\n\n>'))
if result == {}:
    print('unable to reply to post')
else:
    print('replied to %s, %s' % (result['parent'], result['id']))