def main():
    feed = feedparser.parse(
        'https://fedoramagazine.org/feed/')  # read the feed
    try:
        links = pickle.load(open('tweeted_links', 'rb'))  # load posted links
    except FileNotFoundError:
        links = set()  # no link is posted yet

    try:
        bot = TwitterBot(USERNAME, PASSWORD)
        for entry in feed.entries[::-1]:
            link = entry.link
            title = entry.title
            print(title, link)
            if link not in links:
                bot.tweet(title + '\n' + link)
                links.add(link)
        bot.quit()  # quits and clears the chromedriver from memory
    finally:
        pickle.dump(links, open('tweeted_links',
                                'wb'))  # add the posted links to the file
Ejemplo n.º 2
0
# Import the TwitterBot class
from twitterbot import TwitterBot

# create a new bot
bot = TwitterBot("my_username", "my_secret_password")

# tweet
bot.tweet("Hello world from python and selenium")

# quit the bot and close the chrome window
bot.quit()