Esempio n. 1
0
def main(args):
    from colorama import init

    init()
    import consolefont

    consolefont.main()
    r = praw.Reddit("submission stream")
    r.config.decode_html_entities = True
    r.config.log_requests = 0
    from requests.exceptions import HTTPError

    while True:
        try:
            r = praw.Reddit("comment parser")
            r.config.decode_html_entities = True
            r.config.log_requests = 0
            print Fore.YELLOW
            try:
                subreddit = args[1]
            except IndexError:
                subreddit = "+".join(
                    [
                        "physics",
                        "science",
                        "windows",
                        "uknews",
                        "unitedkingdom",
                        "ukpolitics",
                        "london",
                        "news",
                        "worldnews",
                        "europe",
                        "uklaw",
                        "eulaw",
                        "python",
                        "technology",
                        "dota2",
                        "lifeprotips",
                        "gallifrey",
                        "programming",
                        "teslamotors",
                        "startrek",
                        "todayilearned",
                        "iama",
                    ]
                )
                # subreddit = str(raw_input("Enter subreddit:\t"))
            title = "Reddit Comment Tracking: %s" % subreddit
            ctypes.windll.kernel32.SetConsoleTitleA(title)
            subreddit_submissions(r, subreddit)
        except KeyboardInterrupt:
            ctypes.windll.kernel32.SetConsoleTitleA(TITLE)
            print Fore.YELLOW
            break
        except HTTPError:
            logger.exception(Fore.MAGENTA + "\nERROR")
            sleep(5)
            continue
Esempio n. 2
0
        except KeyboardInterrupt:
            ctypes.windll.kernel32.SetConsoleTitleA(TITLE)
            print Fore.YELLOW
        except HTTPError:
            logger.exception(Fore.MAGENTA + "\nERROR")
            sleep(5)
            continue


if __name__ == "__main__":
    import logging

    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger(__name__)
    logger.info("".join([TITLE, " v", VERSION, " ", AUTHOR]))
    import consolefont

    consolefont.main()
    import ctypes

    ctypes.windll.kernel32.SetConsoleTitleA(TITLE)
    import sys
    from time import sleep
    import random
    import datetime
    import textwrap
    import praw
    from praw.internal import RedirectException

    sys.exit(main(sys.argv))