Twint is an advanced Twitter scraping tool written in Python that allows for scraping tweets from Twitter profiles without using Twitter's API. It can fetch tweets, followers, following, retweets, and more while bypassing most of Twitter's limitations. Twint is particularly useful for OSINT investigations, social media monitoring, and research purposes.
⚠️ Legal Notice: Only use Twint for legitimate research, OSINT investigations, or authorized security testing. Respect Twitter's terms of service and applicable privacy laws.
Twint ist ein fortschrittliches Twitter-Scraping-Tool, das in Python geschrieben wurde und es ermöglicht, Tweets von Twitter-Profilen zu sammeln, ohne die Twitter-API zu verwenden. Es kann Tweets, Follower, Followings, Retweets und mehr abrufen und umgeht dabei die meisten Einschränkungen von Twitter. Twint ist besonders nützlich für OSINT-Untersuchungen, Social-Media-Monitoring und Forschungszwecke.
⚠️ Rechtshinweis: Verwenden Sie Twint nur für legitime Forschung, OSINT-Untersuchungen oder autorisierte Sicherheitstests. Respektieren Sie die Nutzungsbedingungen von Twitter und geltende Datenschutzgesetze.
Would you like me to continue with the remaining sections? Please confirm the sections you want me to translate.```bash
# Basic tweet scrapingtwint-uusername
# Scrape tweets with specific search termtwint-s"search term"# Scrape tweets from specific usertwint-uelonmusk
# Limit number of tweetstwint-uusername--limit100# Save to filetwint-uusername-otweets.csv--csv
# Search with date rangetwint-s"cybersecurity"--since"2023-01-01"--until"2023-12-31"
# Get user's tweetstwint-uusername
# Get user's followerstwint-uusername--followers
# Get user's followingtwint-uusername--following
# Get user's favorites/likestwint-uusername--favorites
# Get user informationtwint-uusername--user-full
# Get verified users onlytwint-s"search term"--verified
# Search by keywordtwint-s"cybersecurity"# Search with hashtagtwint-s"#infosec"# Search with multiple keywordstwint-s"cybersecurity OR infosec"# Search for exact phrasetwint-s'"exact phrase"'# Search excluding termstwint-s"cybersecurity -spam"# Search for tweets with linkstwint-s"cybersecurity"--links
# Search for tweets with mediatwint-s"cybersecurity"--media
# Search by locationtwint-s"cybersecurity"--near"New York"# Search with specific languagetwint-s"cybersecurity"--langen
# Search with geolocationtwint-s"cybersecurity"--geo"40.7128,-74.0060,10km"# Search popular tweets onlytwint-s"cybersecurity"--popular
# Search for tweets with minimum likestwint-s"cybersecurity"--min-likes10# Search for tweets with minimum retweetstwint-s"cybersecurity"--min-retweets5
# Search with date rangetwint-s"cybersecurity"--since"2023-01-01"--until"2023-12-31"# Search tweets from specific yeartwint-s"cybersecurity"--year2023# Search tweets from specific hourtwint-s"cybersecurity"--hour14# Search tweets from todaytwint-s"cybersecurity"--since$(date+%Y-%m-%d)# Search tweets from last weektwint-s"cybersecurity"--since$(date-d'7 days ago'+%Y-%m-%d)
# Save as CSVtwint-uusername-ooutput.csv--csv
# Save as JSONtwint-uusername-ooutput.json--json
# Save as text filetwint-uusername-ooutput.txt
# Custom CSV formattwint-uusername--csv--outputtweets.csv--custom-csv"date,time,username,tweet"# Hide output (silent mode)twint-uusername--hide-output
# Debug modetwint-uusername--debug
# Store in Elasticsearchtwint-uusername--elasticsearchlocalhost:9200
# Store in SQLite databasetwint-uusername--databasetweets.db
# Store with custom database tabletwint-uusername--databasetweets.db--table-tweetscustom_tweets
importtwintimportpandasaspddefscrape_user_tweets(username,limit=100):"""Scrape tweets from specific user"""c=twint.Config()c.Username=usernamec.Limit=limitc.Store_pandas=Truec.Hide_output=Truetwint.run.Search(c)# Get pandas dataframetweets_df=twint.storage.panda.Tweets_dfreturntweets_df# Usagetweets=scrape_user_tweets("elonmusk",50)print(f"Scraped \\\\{len(tweets)\\\\} tweets")
importtwintfromdatetimeimportdatetime,timedeltadefadvanced_search(search_term,days_back=7,min_likes=5):"""Advanced search with multiple filters"""c=twint.Config()# Search configurationc.Search=search_termc.Lang="en"c.Min_likes=min_likesc.Popular_tweets=True# Date range (last N days)end_date=datetime.now()start_date=end_date-timedelta(days=days_back)c.Since=start_date.strftime("%Y-%m-%d")c.Until=end_date.strftime("%Y-%m-%d")# Output configurationc.Store_pandas=Truec.Hide_output=True# Run searchtwint.run.Search(c)# Process resultsiftwint.storage.panda.Tweets_dfisnotNone:tweets_df=twint.storage.panda.Tweets_dfreturntweets_dfelse:returnpd.DataFrame()# Usagecybersec_tweets=advanced_search("cybersecurity",days_back=30,min_likes=10)print(f"Found \\\\{len(cybersec_tweets)\\\\} popular cybersecurity tweets")
importtwintimportpandasaspdfromcollectionsimportCounterclassTwitterOSINT:def__init__(self):self.tweets_df=Noneself.users_df=Nonedefanalyze_user(self,username):"""Comprehensive user analysis"""# Get user tweetsc=twint.Config()c.Username=usernamec.Limit=1000c.Store_pandas=Truec.Hide_output=Truetwint.run.Search(c)self.tweets_df=twint.storage.panda.Tweets_dfifself.tweets_dfisnotNoneandnotself.tweets_df.empty:analysis= \\\\{'username':username,'total_tweets':len(self.tweets_df),'date_range': \\\\{'earliest':self.tweets_df['date'].min(),'latest':self.tweets_df['date'].max() \\\\},'engagement': \\\\{'avg_likes':self.tweets_df['likes_count'].mean(),'avg_retweets':self.tweets_df['retweets_count'].mean(),'avg_replies':self.tweets_df['replies_count'].mean() \\\\},'top_hashtags':self.get_top_hashtags(),'top_mentions':self.get_top_mentions(),'posting_patterns':self.analyze_posting_patterns() \\\\}returnanalysiselse:returnNonedefget_top_hashtags(self,top_n=10):"""Extract top hashtags from tweets"""ifself.tweets_dfisNone:return[]all_hashtags=[]forhashtagsinself.tweets_df['hashtags'].dropna():ifhashtags:all_hashtags.extend(hashtags)returnCounter(all_hashtags).most_common(top_n)defget_top_mentions(self,top_n=10):"""Extract top mentions from tweets"""ifself.tweets_dfisNone:return[]all_mentions=[]formentionsinself.tweets_df['mentions'].dropna():ifmentions:all_mentions.extend(mentions)returnCounter(all_mentions).most_common(top_n)defanalyze_posting_patterns(self):"""Analyze posting time patterns"""ifself.tweets_dfisNone:return \\\\{\\\\}# Convert time to hourself.tweets_df['hour']=pd.to_datetime(self.tweets_df['time']).dt.hourpatterns= \\\\{'hourly_distribution':self.tweets_df['hour'].value_counts().to_dict(),'most_active_hour':self.tweets_df['hour'].mode().iloc[0]ifnotself.tweets_df['hour'].emptyelseNone,'daily_tweet_count':self.tweets_df.groupby('date').size().mean() \\\\}returnpatternsdefsearch_and_analyze(self,search_term,limit=500):"""Search for tweets and analyze patterns"""c=twint.Config()c.Search=search_termc.Limit=limitc.Store_pandas=Truec.Hide_output=Truetwint.run.Search(c)self.tweets_df=twint.storage.panda.Tweets_dfifself.tweets_dfisnotNoneandnotself.tweets_df.empty:analysis= \\\\{'search_term':search_term,'total_tweets':len(self.tweets_df),'unique_users':self.tweets_df['username'].nunique(),'top_users':self.tweets_df['username'].value_counts().head(10).to_dict(),'engagement_stats': \\\\{'total_likes':self.tweets_df['likes_count'].sum(),'total_retweets':self.tweets_df['retweets_count'].sum(),'avg_engagement':(self.tweets_df['likes_count']+self.tweets_df['retweets_count']).mean() \\\\},'top_hashtags':self.get_top_hashtags(),'sentiment_indicators':self.basic_sentiment_analysis() \\\\}returnanalysiselse:returnNonedefbasic_sentiment_analysis(self):"""Basic sentiment analysis using keyword matching"""ifself.tweets_dfisNone:return \\\\{\\\\}positive_words=['good','great','excellent','amazing','love','best','awesome']negative_words=['bad','terrible','awful','hate','worst','horrible','disgusting']positive_count=0negative_count=0fortweetinself.tweets_df['tweet'].str.lower():ifany(wordintweetforwordinpositive_words):positive_count+=1ifany(wordintweetforwordinnegative_words):negative_count+=1total_tweets=len(self.tweets_df)return \\\\{'positive_tweets':positive_count,'negative_tweets':negative_count,'neutral_tweets':total_tweets-positive_count-negative_count,'positive_ratio':positive_count/total_tweetsiftotal_tweets>0else0,'negative_ratio':negative_count/total_tweetsiftotal_tweets>0else0 \\\\}# Usage exampleosint=TwitterOSINT()# Analyze specific useruser_analysis=osint.analyze_user("elonmusk")ifuser_analysis:print(f"User Analysis for \\\\{user_analysis['username']\\\\}:")print(f"Total tweets: \\\\{user_analysis['total_tweets']\\\\}")print(f"Average likes: \\\\{user_analysis['engagement']['avg_likes']:.2f\\\\}")print(f"Top hashtags: \\\\{user_analysis['top_hashtags'][:5]\\\\}")# Search and analyze topictopic_analysis=osint.search_and_analyze("cybersecurity",limit=200)iftopic_analysis:print(f"\nTopic Analysis for '\\\\{topic_analysis['search_term']\\\\}':")print(f"Total tweets: \\\\{topic_analysis['total_tweets']\\\\}")print(f"Unique users: \\\\{topic_analysis['unique_users']\\\\}")print(f"Average engagement: \\\\{topic_analysis['engagement_stats']['avg_engagement']:.2f\\\\}")