Created
April 23, 2024 00:28
-
-
Save cometothed4rkside/21e90ea38f75873ab2cb667fc28046ed to your computer and use it in GitHub Desktop.
Twitter İtibar Takibi // Gmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import smtplib | |
| from email.message import EmailMessage | |
| import time | |
| from twikit import Client | |
| USERNAME = '' #Twitter kullanıcı adınız | |
| EMAIL = '' #Twitter e-posta adresiniz | |
| PASSWORD = '' #Twitter Şifreniz | |
| APP_PASSWORD = '' #https://myaccount.google.com/apppasswords adresinden 16 haneli şifre oluşturun ve buraya ekleyin. | |
| def send_email(subject, message_text): | |
| msg = EmailMessage() | |
| msg.set_content(message_text) | |
| msg['Subject'] = subject | |
| msg['From'] = EMAIL | |
| msg['To'] = "" #Maillerin gönderileceği e-posta adresi | |
| try: | |
| with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: | |
| smtp.login(EMAIL, APP_PASSWORD) | |
| smtp.send_message(msg) | |
| print('Mail gönderildi') | |
| except Exception as e: | |
| print(f'Mail gönderilemedi: {e}') | |
| def monitor_tweets(): | |
| client = Client('tr-TR') | |
| client.login( | |
| auth_info_1=USERNAME, | |
| auth_info_2=EMAIL, | |
| password=PASSWORD | |
| ) | |
| last_tweet_id = None | |
| while True: | |
| try: | |
| tweets = client.search_tweet('Mansur Yavaş', 'Latest') | |
| for tweet in tweets: | |
| if tweet.id != last_tweet_id: | |
| last_tweet_id = tweet.id | |
| print(f"{tweet.user.name}: {tweet.text}\n") | |
| send_email('Mansur Yavaş hakkında yeni bir tweet var', f'{tweet.user.name}: {tweet.text}') | |
| time.sleep(10) | |
| except Exception as e: | |
| print(f"Tweetler çekilemedi: {e}") | |
| time.sleep(60) | |
| if __name__ == "__main__": | |
| monitor_tweets() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment