├── README.md ├── replies_clean.csv └── twitter_reply.py /README.md: -------------------------------------------------------------------------------- 1 | # Get-Tweet-Replies-With-Python-Tweepy 2 | ## Extract Replies to a Specific Tweet using Python and Tweepy 3 | 4 | I was searching for an easy way to extract the replies of a certain tweet. After no success searching open-source code I decided to try this, and it works! 5 | 6 | You will want to have a [Twitter Developer account](https://developer.twitter.com/) and you will need to add your keys within the code. 7 | 8 | Navigate to where you downloaded your code, assuring you have [Tweepy](https://www.tweepy.org/) installed within the same environment. 9 | 10 | Run 11 | 12 | ```python 13 | python3 twitter_reply.py 14 | ``` 15 | The replies will be in a .csv file within the same directory. 16 | 17 | * Twitter has updated their API in which you will need an elevated API access, I am working on a workaround. * 18 | 19 | Except as represented in this agreement, all work product by Developer is provided ​“AS IS”. Other than as provided in this agreement, Developer makes no other warranties, express or implied, and hereby disclaims all implied warranties, including any warranty of merchantability and warranty of fitness for a particular purpose. 20 | 21 | -------------------------------------------------------------------------------- /replies_clean.csv: -------------------------------------------------------------------------------- 1 | user,text 2 | ricardobarq,@LunarCRUSH @nimiq for sure! Working in super innovative tech and has the best #community in #crypto 3 | CWM514,@LunarCRUSH #DGB $DGB 4 | AmoreLoveAmor,@LunarCRUSH DigiByte https://t.co/4OxE2SMbl6 5 | oucan_dvt,@LunarCRUSH $DVT 🔥😎 #ColdRewards 6 | uribem001,@LunarCRUSH Easy... #Zilliqa 7 | RReinier3,@LunarCRUSH Zilliqa! 8 | ava_csc,@LunarCRUSH $CSC and $AVA Both CasinoCoin and Travala have amazing teams that deliver amazing technology to it's am… https://t.co/XOOdclXfbv 9 | TOMO_MeKONG,@LunarCRUSH $TOMO #DeFi P2P Lending +++ https://t.co/b9zR3A6AaY 10 | jeffpisarek,@LunarCRUSH $ICX doing huge things. On both fronts. Love this project and community. 11 | fredostat,@LunarCRUSH @vechainofficial $vet #vechain 12 | ChainOligarch,@LunarCRUSH #Digibyte @DigiByteCoin $Digibyte #SleepingGiant 13 | mass_adoption,@LunarCRUSH Easy answer. Undoubtedly #CasinoCoin. An absolute Rockstar team & the most mature and genuine community… https://t.co/Tm7I9aryuy 14 | bigfloater74,@LunarCRUSH $icx for sure! 15 | wkwwwwk,@LunarCRUSH $ICX !! 16 | Aravolp,@LunarCRUSH $Divi https://t.co/Jg3wxH9bNW 17 | MicorEkzema,@LunarCRUSH #vet #hbar #icx #ada #xrp #0doubt 18 | vednigam3,@LunarCRUSH #Zilliqa and i m not saying it u are telling us with facts and figures 💯💯🔥 19 | JamesMRO1,@LunarCRUSH Daps Coin 💪 #daps 🤩 20 | donifaciuk1,@LunarCRUSH #DAPScoin of course https://t.co/tiQxl81zoi 21 | coinspotbot,"@LunarCRUSH DeFi tokens are delivering big time in 2020. $CHZ @Chiliz might not be the biggest community, but it is… https://t.co/1jtVoGVMZp" 22 | icon_deutsch,@LunarCRUSH $icx pretty clear to me 23 | TheCryptoZap,@LunarCRUSH $UBT @UnibrightIO 💯 24 | Ll0ydV0id,@LunarCRUSH $NEX @nashsocial fits perfectly with that description 👀 25 | JennyFr89312299,"@LunarCRUSH @ShareRingGlobal ($SHR) not only has a product used by normal people, without even knowing it, they hav… https://t.co/A0AlsGv2e9" 26 | CryptoGrills,"@LunarCRUSH @ShareRingGlobal really stands out in this perspective, they have never stopped building. All these lo… https://t.co/NbaeOF7KBq" 27 | berman_kahar,@LunarCRUSH $SERO @SEROdotCASH 28 | skullder_,"@LunarCRUSH Make no mistake, it’s #VeChain" 29 | sjakie46390779,"@LunarCRUSH @ShareRingGlobal it’s entire platform&ecosystem has a wide range of valid usecases, products and servic… https://t.co/Ix4rOLPhgF" 30 | CryptoKingNL,@LunarCRUSH $ICX #ICONPROJECT 31 | CryptoEntuziast,@LunarCRUSH @zilliqa ofcourse 🚀🚀🚀😎😎😎 32 | ecossexrp1,@LunarCRUSH $VET $XRP 👌🏻 33 | crypto19711,@LunarCRUSH @DAPScoin the best privacy coin in this world! https://t.co/xFHs3cYFmK 34 | lacryptohero,@LunarCRUSH @Theta_Network 35 | Greenmi74576867,@LunarCRUSH https://t.co/vwmznwu77V 36 | SplendidMite,@LunarCRUSH #VeChain $VET 37 | DAPS_CLimaDelta,"@LunarCRUSH Because I am judging a project for the best technology, transparency, reliable team and dedicated commu… https://t.co/6xS9vdx1oY" 38 | DigiBur,@LunarCRUSH #digibyte 39 | M_SRHI,@LunarCRUSH $ICX 💎 $ELA 💎❤️ $NOIA💎 40 | SURAJ_041,@LunarCRUSH @electroneum #ETN . 41 | GbhoyDownUnder,@LunarCRUSH @maticnetwork 42 | jodibreeze86,@LunarCRUSH Zilliqa and Vechain 43 | ghurabar1,@LunarCRUSH $EWT 44 | SamManzi,@LunarCRUSH @NoiaNetwork @NoiaFr $NOIA 45 | IamDavidGC,@LunarCRUSH Proud of DigiByte community and technology. $dgb 46 | holder2017,@LunarCRUSH @Falcon_SBS #FNT token traded on #exchanges. #Anonymous coin #FNC is not traded anywhere. connected b… https://t.co/0mz7bmaG1k 47 | Lilt8888,@LunarCRUSH It would have to be $ICX 48 | Creeptwo_guy13,@LunarCRUSH That question is way too easy. Absolutely its $ICX #ICON. 49 | BitStreetSheep,@LunarCRUSH #VeChain without question 50 | jms3333333,@LunarCRUSH LInk UBT KNC EWT SOLVE 51 | einnorka,@LunarCRUSH Digibyte 52 | wildnwity,"@LunarCRUSH #zilliqa over delivered *the promised, Their promise was for #sharding implemented #blockchain,… https://t.co/ybVuEMB2Xg" 53 | HamishDonalds0n,@LunarCRUSH $icx $vet $zil $ada $eth $link 54 | amity3013,@LunarCRUSH $zil you know it 55 | elianhuesca,"@LunarCRUSH @decredproject by far: hybrid PoW/PoS blockchain, formal governance in place, Treasury with 10% of bloc… https://t.co/oRnMc4UD5P" 56 | AaronMilo,@LunarCRUSH #digibyte https://t.co/000HoTfLqB 57 | majjjubu,@LunarCRUSH Chz 58 | Benjy25680913,@LunarCRUSH $LUNARCRUSH 59 | ItchyTommi,@LunarCRUSH https://t.co/y8l2WwP3qK Stakenet. The one and only 60 | siggebaskero,@LunarCRUSH #PIVX thanks to @PIVX_Community who's doing a great job 💜 Engaging with a growing community like… https://t.co/CBlhJm7gZj 61 | DanXrp,@LunarCRUSH $VET no doubt 62 | crypto1618,@LunarCRUSH #icx 63 | thelionshire,@LunarCRUSH ICON $icx 64 | ChillMa27939777,@LunarCRUSH #Zilliqa #ZIL ✌😎 65 | BeholdTheBeard,@LunarCRUSH Tezos $XTZ Theta $THETA 66 | lennyshots,@LunarCRUSH #DigiByte 67 | Shatochzi,@LunarCRUSH $CHZ #chiliz 68 | RonDalton01,@LunarCRUSH #VET 69 | Realmikeleonard,@LunarCRUSH #XMR no doubt about it 70 | Incognitor00st1,@LunarCRUSH $DGB 🔥 71 | Cryptowhale10,@LunarCRUSH $ICX https://t.co/WQTbyPkpEB 72 | XxVegetta,@LunarCRUSH We are DAPS soliders I have been dedicated to our project for 2 years and I think for many years to co… https://t.co/QLk7kKJkhk 73 | CaliCryptoCo,@LunarCRUSH $ICX man 74 | MoonShotCaller,@LunarCRUSH #VeChain 💙 $VET 75 | Dominic_LTC_DGB,@LunarCRUSH @DigiByteCoin 76 | GrowlerGregg,@LunarCRUSH $LINK 77 | adflondon,@LunarCRUSH We all know its $ICX 78 | SajawalOnTech,@LunarCRUSH To many projects but I guess $Wan $link $Zil $Icx 79 | IconPilipinas,@LunarCRUSH $ICX 80 | jonade,@LunarCRUSH $ZIL 81 | twills2,@LunarCRUSH Do we really have to say it...... $zil 🚀 82 | -------------------------------------------------------------------------------- /twitter_reply.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import tweepy 3 | import ssl 4 | 5 | ssl._create_default_https_context = ssl._create_unverified_context 6 | 7 | # Oauth keys 8 | consumer_key = "XXX" 9 | consumer_secret = "XXX" 10 | access_token = "XXX" 11 | access_token_secret = "XXX" 12 | 13 | # Authentication with Twitter 14 | auth = tweepy.OAuthHandler(consumer_key, consumer_secret) 15 | auth.set_access_token(access_token, access_token_secret) 16 | api = tweepy.API(auth) 17 | 18 | # update these for the tweet you want to process replies to 'name' = the account username and you can find the tweet id within the tweet URL 19 | name = 'tenderize_me' 20 | tweet_id = '1745799013025394937' 21 | 22 | replies=[] 23 | for tweet in tweepy.Cursor(api.search,q='to:'+name, result_type='recent', timeout=999999).items(1000): 24 | if hasattr(tweet, 'in_reply_to_status_id_str'): 25 | if (tweet.in_reply_to_status_id_str==tweet_id): 26 | replies.append(tweet) 27 | 28 | with open('replies_clean.csv', 'w') as f: 29 | csv_writer = csv.DictWriter(f, fieldnames=('user', 'text')) 30 | csv_writer.writeheader() 31 | for tweet in replies: 32 | row = {'user': tweet.user.screen_name, 'text': tweet.text.replace('\n', ' ')} 33 | csv_writer.writerow(row) 34 | --------------------------------------------------------------------------------