main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:TwitterStockMonitor 作者: semaaJ 项目源码 文件源码
def main():
    # Checks if this is the first time running the script
    # Allows the user to choose the Twitter Handles to follow
    # Sets the TWITTER_HANDLES which is an empty list, to the new updated list
    if INITIAL_START:
        handles = initial_start()
    else:
        handles = TWITTER_HANDLES

    # Sets up share_output job
    twit = Twitter()
    schedule.every().day.at("18:17").do(twit.share_output)
    schedule.every(15).minutes.do(company.current_day)

    while True:
        for handle in handles:
            twitter = Twitter(handle)

            new_tweet = twitter.get_latest_tweet()

            # Checks if a new tweet has been posted
            # If it has, checks for companies within the tweet
            if new_tweet:
                matches = company.check_for_companies(new_tweet, handle)

                # If there is a company mentioned
                if matches:
                    # Gets the initial company info
                    company.get_initial_company_info()

                    # Outputs the matches via twitter/email
                    twitter.initial_tweet(matches)
                    email(handle, matches)

            # Checks mentions for sign ups/removals
            twitter.check_mentions()

        # Gets current share price for each company being monitored
        # Checks if there are any schedules to be run
        company.get_current_shares()
        schedule.run_pending()

        now = datetime.now()
        print(f'Running: {now.hour}:{now.minute} - {now.day}/{now.month}/{now.year}')
        sleep(10)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号