def get_top_submissions(): titles = "<ul>" reddit = Reddit() reddit.open_reddit_read() submissions = reddit.top_submissions('u_hansknecht', 5) for entry in submissions: titles += "<li>{0}</li>".format(entry.title) titles += "</ul>" return titles
def __init__(self): # Single file that all output is written to, to track usage self.exit_if_already_started() self.db = DB() # Database instance log_level = self.db.get_config('log_level', default='user') if log_level == 'none': self.root_log = open(devnull, 'w') else: self.root_log = open( path.join(ImageUtils.get_root(), 'history.log'), 'a') self.logger = self.root_log # Logger used by helper classes self.reddit = Reddit() self.excluded_subs = self.db.get_excluded_subreddits()
def __init__(self): # Single file that all output is written to, to track usage self.exit_if_already_started() self.root_log = open(path.join(ImageUtils.get_root(), 'history.log'), 'a') self.logger = self.root_log # Logger used by helper classes self.db = DB() # Database instance self.reddit = Reddit() try: (username, password) = self.db.get_credentials('reddit') try: self.reddit.login(username, password) except Exception, e: self.debug('__init__: failed to login to reddit: %s' % str(e)) except Exception, e: self.debug('__init__: failed to get reddit credentials: %s' % str(e))
from SQLHandler import SQLHandler from Reddit import Reddit from Analyzer import Analyzer import time def thenOrThan(words): return "then" if "then" in words else "than" count = 0 while True: sql = SQLHandler() reddit = Reddit() analyzer = Analyzer() count += 1 print "Beginning Iteration " + str(count) print "Gathering Comments" comments = reddit.getNewComments() views = sql.getViews() print "Processing Data" for comment in comments: flag = True words = [x.lower().strip() for x in comment[0].split()] thenorthan = thenOrThan(words)
def __init__(self): self.data = Data() self.teams = Teams() self.scoreboard = Scoreboard() self.reddit = Reddit('nba')
''' Created on Oct 14, 2017 @author: Tyler-OC ''' from Discord_API import Discord from Database import Database from Reddit import Reddit import time discord = Discord() Data = Database() Red = Reddit() count = 0 while True: Page = Red.getPage("https://www.reddit.com/r/buildapcsales/") Products = Red.getProducts(Page) for product in Products: if "[monitor]" in product.lower(): if Data.CheckProduct(product): print("Product in database!") else: Data.newProduct(product, Products[product]) Message = "There is a new Product to Check out! \n" + product + "\n" + Products[product] discord.sendMessage(Message)
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div class="container mb-5"> <h1>Your feed for {today.strftime('%d %b %Y')}</h1> """) w = Weather() w.write_weather() e = Events() e.write_events() r = Reddit() with open(feed_path, "a") as file: file.write("<h2>Reddit</h2>") r.fetch_subs_and_write("reactjs") r.fetch_subs_and_write("webdev") r.fetch_subs_and_write("frontend") r.fetch_subs_and_write("python") r.fetch_subs_and_write("rollerblading") with open(feed_path, "a") as file: file.write("<h2>CNA</h2>") cna = CNA()
def lambda_handler(event, context): red = Reddit() return red.scan()
from Reddit import Reddit if __name__ == '__main__': f = open("dictionaries/insultos.txt", "r") paraulesclau = f.readlines() f.close() f = open("dictionaries/topics.txt", "r") paraulesclau += f.readlines() f.close() index = 0 for p in paraulesclau: paraulesclau[index] = p[:-1].lower() index += 1 # print(paraulesclau) #inicialitzem reddit Reddit('comments', paraulesclau)
def setUp(self): self.reddit = Reddit() return super().setUp()
pass elif (sys.argv[flag] == "--image" or sys.argv[flag] == "-i"): pass elif (sys.argv[flag] == "--nsfw" or sys.argv[flag] == "-NSFW"): pass elif (sys.argv[flag] == "--" or sys.argv[flag][0] != "-"): break else: print("invalid flag", sys.argv[flag]) usage() r = Reddit(User) bot = 'bot1' d = Display(praw.Reddit(bot, user_agent=bot)) if (argc > shift + 1 and (sys.argv[shift + 1] == "list" or sys.argv[shift + 1] == "l")): pass elif (argc > shift + 1 and (sys.argv[shift + 1] == "print" or sys.argv[shift + 1] == "p")): pass elif (argc > shift + 1 and (sys.argv[shift + 1] == "collect" or sys.argv[shift + 1] == "c")): payload = r.updown(Sub)
#!/usr/bin/env python # -*- coding: utf-8 -*- from HackerNews import HackerNews from Reddit import Reddit from RSS import RSS from Tweet import Tweet # CONSTANTS RETRIES = 10 # Number of retries on URL failure WAIT_TIME = 20 * 60 # Time to wait between posting (in seconds) tweet = Tweet() if (tweet.check_last_tweet()): news = HackerNews(WAIT_TIME) news.tweet_stories(5) reddit = Reddit(WAIT_TIME) reddit.tweet_stories(3) rss = RSS(WAIT_TIME) rss.tweet_stories(2)
def __init__(self, username, password, clientId, clientSecret): self.reddit = Reddit(username, password, clientId, clientSecret)
SK = Skyrock(json['login'], json['pass'], json['text'], json['link'], json['datetime'], json['page_post'], json['groupe_post'], json['title'], json['image_link'], json['hashtags'], json['gropes_links'], json['priority']) SK.post() print(SK.get_bugrep()) if json['id'] == 'wh': WH = WeHear(json['login'], json['pass'], json['text'], json['link'], json['datetime'], json['page_post'], json['groupe_post'], json['title'], json['image_link'], json['hashtags'], json['gropes_links'], json['priority']) WH.post() print(WH.get_bugrep()) if json['id'] == 'rd': RD = Reddit(json['login'], json['pass'], json['text'], json['link'], json['datetime'], json['page_post'], json['groupe_post'], json['title'], json['image_link'], json['hashtags'], json['gropes_links'], json['priority']) RD.post() print(RD.get_bugrep()) if json['id'] == 'li': LI = LinkedIn(json['login'], json['pass'], json['text'], json['link'], json['datetime'], json['page_post'], json['groupe_post'], json['title'], json['image_link'], json['hashtags'], json['gropes_links'], json["priority"]) LI.post() print(LI.get_bugrep()) if json['id'] == 'tr': TR = Tumblr(json['login'], json['pass'], json['text'], json['link'], json['datetime'], json['page_post'], json['groupe_post'], json['title'], json['image_link'], json['hashtags'], json['gropes_links'])
def main(): # Just a quick note. I prefer camelCase over underscores so that is what I used for the variable names I changed. authFile = "auth.txt" creds = import_credentials(authFile) if creds is False or len(creds) < 3: print("The OAuth file is not valid, or it does not exist.") print("Please provide valid OAuth credentials in ", authFile, ".", sep="") sys.exit( ) # sys.exit() is I believe the more pythonic way of doing this. # sys.exit() is meant more for programs where as exit(0) is meant for the interactive console. I think. else: reddit = Reddit(*creds) # By creating a Reddit object we don't need to worry about passing credentials when we want to use the, inital_user = input("Enter username (enter 'q' to quit): ") if inital_user == "q": # Why don't you just do this? sys.exit() print("Getting original user's top 5 subreddits...") # Original user's top 5 subreddits top_subreddits = reddit.ranked_subreddits( reddit.full_comment_and_submission_history(inital_user), max_count=10) user_scores = {} # Set this to the maximum number of latest users you want from each subreddit MAX_USERS_PER_SUBREDDIT = 100 # Last 100 users in each of the top 5 subreddits for sub_count, sub_reddit in enumerate( top_subreddits ): # enumerate gets you a iterable and an index variable # In this case sub_count was just the index+1 print("Getting last 100 users in " + sub_reddit[0] + " (" + str(sub_count + 1) + " of " + str(len(top_subreddits)) + ")...") users_list = reddit.last_subreddit_users( sub_reddit[0], max_count=MAX_USERS_PER_SUBREDDIT) # Top 5 subreddits for each of the users in the current subreddit user_count = 1 for user in users_list: print("Getting top subreddits for user " + str(user_count) + " of " + str(len(users_list)) + "...", end="\r", flush=True) user_top_subreddits = reddit.ranked_subreddits( reddit.full_comment_and_submission_history(user), max_count=5) score = 1 user_count += 1 for comp_sub in user_top_subreddits: if comp_sub in top_subreddits: score += 1 if score > 1: user_scores.update({user: score}) print("\nMatched users so far: " + str(user_scores)) matched_users = sorted(user_scores.items(), key=operator.itemgetter(1), reverse=True) print("\nUsers most like " + inital_user + ":") for match in matched_users: print("User: "******" | Score: " + str(match[1]))