Пример #1
0
if __name__ == "__main__":
    username = environ["USERNAME"]
    consumer_key = environ['KEY']
    consumer_secret = environ['SECRET']
    access_token = environ['TOKEN']
    access_token_secret = environ['TOKEN_SECRET']
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth, wait_on_rate_limit=True)
    mad_bot = TwitterActions(api, username)

    while True:

        get_quote = Quotes()
        qotd = [
            get_quote.brainy(),
            get_quote.good_reads(),
            get_quote.good_housekeeping(),
            get_quote.keep_inspiring()
        ]
        random.shuffle(qotd)

        scrape = Websites()
        websites = [
            scrape.web(abc, 'doctype-article', abc[:-6], 'a', 'abcnews'),
            scrape.web(nine, 'feeds', nine, 'h3', 'ninenews'),
            scrape.web(bbc, 'media-list__item media-list__item--1', bbc, 'a',
                       'bbcnews'),
            scrape.web(ny_times, 'css-1qiat4j eqveam63', ny_times[:-1], 'h2',
                       'nytimes'),
            scrape.web(the_star, 'col-sm-3 in-sec-story', the_star, 'h2',
Пример #2
0
    username = os.getenv("USERNAME")
    consumer_key = os.getenv("KEY")
    consumer_secret = os.getenv("SECRET")
    access_token = os.getenv("TOKEN")
    access_token_secret = os.getenv("TOKEN_SECRET")
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
    auth.set_access_token(access_token, access_token_secret)
    api = tweepy.API(auth, wait_on_rate_limit=True)

    mad_bot = TwitterActions(api, username)

    while True:
        choice = display_menu(menu)
        if choice == 1:
            get_quote = Quotes()
            link = [get_quote.brainy(),
                    get_quote.good_reads()]
            random.shuffle(link)
            for i in range(len(link)):
                mad_bot.tweet_quote(link[i])
        elif choice == 2:
            mad_bot.tweet_random()
        elif choice == 3:
            url = input("Paste url: ")
            mad_bot.tweet_summary(url)
        elif choice == 4:
            scrape = Websites()
            link = [scrape.ny_times(),
                    scrape.nine_news(),
                    scrape.the_star(),
                    scrape.abc(),