def run(args, parser, reddit): """ Run Subreddit scraper. Calls previously defined public methods: RunSubreddit._create_settings() RunSubreddit._write_file() Calls a method from an external module: PRAWTitles.r_title() Parameters ---------- args: Namespace Namespace object containing all arguments that were defined in the CLI parser: ArgumentParser argparse ArgumentParser object reddit: Reddit object Reddit instance created by PRAW API credentials Returns ------- s_master: dict Dictionary containing all Subreddit scrape settings """ PRAWTitles.r_title() s_master = RunSubreddit._create_settings(args, parser, reddit) RunSubreddit._write_file(args, reddit, s_master) return s_master
def run(args, parser, reddit): """ Run basic Subreddit scraper. Calls previously defined public and private methods: ConfirmInput.another() RunBasic._create_settings() RunBasic._print_confirm() Calls public methods from external modules: GetSortWrite().gsw() PRAWTitles.b_title() Parameters ---------- args: Namespace Namespace object containing all arguments that were defined in the CLI parser: ArgumentParser argparse ArgumentParser object reddit: Reddit object Reddit instance created by PRAW API credentials Returns ------- master: dict Dictionary containing all Subreddit scrape settings """ PRAWTitles.b_title() while True: master = RunBasic._create_settings(parser, reddit) confirm = RunBasic._print_confirm(args, master) if confirm == options[0]: break else: print(Fore.RED + Style.BRIGHT + "\nExiting.\n") parser.exit() GetSortWrite().gsw(args, reddit, master) return master
def run(args, parser, reddit): """ Run comments scraper. Calls previously defined public methods: CheckSubmissions.list_submissions() Write.write() Calls public methods from external modules: GetPRAWScrapeSettings().create_list() GetPRAWScrapeSettings().get_settings() Global.make_none_dict() PRAWTitles.c_title() Parameters ---------- args: Namespace Namespace object containing all arguments that were defined in the CLI parser: ArgumentParser argparse ArgumentParser object reddit: Reddit object Reddit instance created by PRAW API credentials Returns ------- c_master: dict Dictionary containing all submission comments scrape settings """ PRAWTitles.c_title() post_list = GetPRAWScrapeSettings().create_list(args, s_t[2]) not_posts, posts = CheckSubmissions.list_submissions( parser, post_list, reddit) c_master = make_none_dict(posts) GetPRAWScrapeSettings().get_settings(args, not_posts, c_master, s_t[2]) Write.write(args, c_master, reddit) return c_master
def _set_info_and_object(args, reddit): """ Set the stream information and Reddit object based on CLI args. Parameters ---------- args: Namespace Namespace object containing all arguments that were defined in the CLI reddit: PRAW Reddit object Returns ------- reddit_object: PRAW Subreddit or Redditor object stream_info: str String denoting the livestream information """ if args.live_subreddit: PRAWTitles.lr_title() Validation.validate([args.live_subreddit], reddit, "subreddit") initial_message = f"Initializing Subreddit livestream for r/{args.live_subreddit}." stream_info = f"in r/{args.live_subreddit}" reddit_object = reddit.subreddit(args.live_subreddit) elif args.live_redditor: PRAWTitles.lu_title() Validation.validate([args.live_redditor], reddit, "redditor") initial_message = f"Initializing Redditor livestream for u/{args.live_redditor}." stream_info = f"by u/{args.live_redditor}" reddit_object = reddit.redditor(args.live_redditor) Halo().info(Fore.CYAN + Style.BRIGHT + initial_message) logging.info(initial_message + "..") Halo().info("New entries will appear when posted to Reddit.") return reddit_object, stream_info
def run(args, parser, reddit): """ Get, sort, then write scraped Redditor information to CSV or JSON. Calls a previously defined public method: Write.write() Calls public methods from external modules: GetPRAWScrapeSettings().create_list() Validation.validate() Global.make_none_dict() GetPRAWScrapeSettings().get_settings() Parameters ---------- args: Namespace Namespace object containing all arguments that were defined in the CLI parser: ArgumentParser argparse ArgumentParser object reddit: Reddit object Reddit instance created by PRAW API credentials Returns ------- u_master: dict Dictionary containing all Redditor scrape settings """ PRAWTitles.u_title() user_list = GetPRAWScrapeSettings().create_list(args, "redditor") not_users, users = Validation.validate(user_list, parser, reddit, "redditor") u_master = make_none_dict(users) GetPRAWScrapeSettings().get_settings(args, not_users, u_master, "redditor") Write.write(args, reddit, u_master) return u_master