Python Project - Building Twitter Bot With Python and Tweepy | Shubham Sarda | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Python Project - Building Twitter Bot With Python and Tweepy

teacher avatar Shubham Sarda, Python Developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

17 Lessons (1h 3m)
    • 1. Course Introduction

    • 2. Creating Twitter Developer Account

    • 3. Creating App and Generation Access Tokens

    • 4. Installing Tweepy

    • 5. Update Status Through Bot

    • 6. Introduction To Auto-Reply

    • 7. Working With Timeline and Mentions

    • 8. Iterate Tweets And Add Condition

    • 9. Storing Replied Tweet ID's

    • 10. Storing-Accessing Last Seen ID

    • 11. Replying Tweet

    • 12. Formatting Function and Testing Bot

    • 13. Auto Retweet and Auto Like

    • 14. Setting-up PythonAnyWhere

    • 15. Deployment Done Along Testing

    • 16. Auto Retweet To Particular Hashtag

    • 17. Implementing Error Handling And Testing Bot

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Welcome to Building Twitter Bot With Python and Tweepy,
This course will help you to build Twitter Bot project Step-by-Step with Tweepy and Twitter Developer Free API, after development we will deploy bot online to work 24/7.

Build Your Twitter Bot To - 
1. Auto Reply
2. Auto Retweet
3. Auto Favorite/Like
4. Auto Search and More!

Throughout the course we you will learn more about Python and Tweepy,
1. Understanding Twitter API and its usage with Tweepy.
2. Extracting Timeline Data and working with it.
3. Building logic to work on data and perform function on extracted data.
4. Getting started by updating our first status through Terminal.
5. Completing Auto Reply Bot used for hashtags.
6. Completing Auto Retweet and Like for particular search.
7. Deploying Bot Online - Working 24/7

After completing this course you will be ready to expand your knowledge over Automation and Python.
Enroll now and I will make sure you learn best about Tweepy!

Meet Your Teacher

Teacher Profile Image

Shubham Sarda

Python Developer


Hey there!

I've created Complete Roadmap to become a Developer with different projects, specifically for the SkillShare audience. 

With this roadmap we will start with Python Programming, learn about basics, important concepts and solve some real life problems by building projects. Once we are ready with Python, its time to gain more experience with different field projects in Automation, Data Analysis, GUI Programming and Web Development. 

Here is Complete Python Programming - 
Python A-Z: Learn Python Programming By Building Projects
Python Programming - Advanced Concepts

Python Projects - 
Python Project - Building Twitter Bot With Python and Tweepy
Python GUI Programming - Build a Desktop Application with Tkinter and SQLit... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Course Introduction: Hey, guys, Welcome to basics off fight on commission building with a board with fight on and to empire . Have you ever wanted to automate something by learning? This course will help you to follow that you will learn how daughter replied to tax. Like big companies, Twitter customer support do automatically redo eating user status or maybe liking some random status for particular hashtag to get attention all. Maybe you want to automate something else with Twitter after the schools, you will be easily able to follow that. Not only this, by the end of the schools, you will also learn how to deploy our board on a virtual online. Silver should keep running 24 7 and you can see the automated present to begin. All you need is basic fight on Ali interested to automate a Twitter account and roll into the scores. And I'm really excited to see you inside 2. Creating Twitter Developer Account: Hey, guys, Welcome back. Now, in this lecture we'll be talking about how to create a developer account, how to get our developer a p a and how to get different accents that we need to control our Twitter account before doing anything else. Make sure you have to account. The 1st 1 will be the count we are going to control. So I would be using on wire learning account on making it automated so I would be creating older developer A pay for this particle at a con. And we also need a second account to actually test the functionalities off Foster con. So if I tweet something from my second account tagging my fast account, I should be able to get a reply from my faster come. That means I'm going to control everything for my first account through my director board. So this is the count I'm going to control. And the second account that I'm using wood before test focus. Now, the next thing is, we need to create developer ap a. So just jump onto Google and search for developer to Italian B A. Now, this is the link that you need to focus on. Make sure you are logged in from the conference you want to control. So here I'm logged in from my unwired landing account. Now here, you need to click on apply. Remember, there are two process. First, we need to apply. This might take some time. We need to get our application cleared. Once that is done, we need to create AB. And from that after we are going to get access token, which can help us to control our Twitter account from our board. So simply just click on, apply for a developer account on head. What? I would be asking some details. Now You want to stay below, but account for professional use. That is commercial use. It's your hobby. Some personal project on Lord morning, I would be going with the basic option just to make a board. Now make sure you are a countess Phone verified. If not, you need to verify your account and then filled 13 d din's here. You just want to enter your account name and then once you click on next, Twitter will ask you that what you are going to do with this particle at a p A on how you're going to use this particular data. All you have to do is just filler detail that you are creating a practice board. Are you are creating a board to manager account or something like that One status done. Just simply select all the options regarding this specification so they might ask you how you are going to use this. A p a. So are you going to use the state? Are you going to retweet like or something like this? Just fill this up and make sure you give valid answer. Certainly convincing for Twitter team to approve your A p A. Yes, click on next and this looks good. All we have to do is just accept their dumps in condition and we need to verify army. So jump onto a mail address and see you have got a confirmation mail on or the confirmation meal would look something like this. All you have to do is just click on, confirm your email, Dotson And it was quite simple, I guess. And I hope you understand about this. The next thing I need to talk about this to create up. So all we need to do is we need to work on this. Create an app that will be doing in next lecture. I hope creating a developer account is quite easy. All you have to do is just use a valid Twitter account at this email verified as well as phone verified on, you need to have a valid reason. Just give a valid reason that you are creating a board for educational purposes. That son in the next littler to stalk about creating are up. And then how do axes are? Totally P A. Thank you for falling this lecture. See you in the next one. 3. Creating App and Generation Access Tokens: Welcome back. Now, in this lecture we need to create an up. One thing you can do is just click on, create an up or the first somewhere on the dashboard or any other page. Polly after is just going to ab section on Dhere. You will have an option. Create an app. Now app is really important for this process. Since we're going to take permission off our account to up solely after this just gave a particle a name to this up I would be using you Will tweets. That is on my learning tweet On next. We need to get her description. So what we are going to do with this particle arap We're goingto otomi datacom. So that would be like to eat and come in when you have to give up settling. If you have a website, that's fine. If you don't have a website, just copy your profiling and submit. That will work totally fine. So if you have over upset, just give you upside Ling as you can try out your retelling One status done. You can just scroll down and see what are the remaining required feels here they will be asking what we are going to rule with this particular up. So we have already mentioned that in description. Let me copy base my description here and complete my word limit off 100 characters. And once we're done with this description, just click on, create on. You have to just read the basic terms and then click on create That's done on hair is are important thing. That is our keys and tokens. So all you have to do is just creator access. Tokcan, these food are really important. Since via these folkies, anyone can control your account. So after recording the schools, I'm going to regenerate them. So anyone who is watching these keys cannot utilize them. So you have to be really careful regarding this keys. Just keep these four key safely with yourself only on make sure your permission is for read and write. That means we can access data as well as we can write their data. So that's all for this lecture. In the next lecture, let us jump onto our text reader and start working with our code. Thank you for falling this lecture. See you in the next one. 4. Installing Tweepy: Hey, guys, Welcome back in this lecture, we are going to install our library call to reply. So this is the main library that help us to build to it. Aboards. Now remember, we are currently using its latest words. And for now, which is 3.7 point O on. Remember, I'm also using python 3.7. So you have to take care of the words in off fight on as well. A strip fire. Let me jump onto my full A structure as well. So her. I've created a fuller on my deck stop, which is terribly work. And all the finals regarding my Twitter board would be inside this. So let me open my command from on Install three pie. And as always, if you are a Mac user, just open your terminal. And after that, all we have to do is just use Pip install to reply on one status than we goto. Now we can actually utilize our tweet by library. We can imported in our files. The next step is you need to create a north by If I so let me create my board dot by So here, let me open my visual studio cold or whatever the text editor you are using, I would be using the escort you can use by charm atom B escort, whatever you want. And then inside that I need to open my particle a folder that has stayed a Blue War. And once I open that folder, I just need to create my board dot By and once that distant, let me check if my reply is install or not, so you have to do is just use import we buy and let me just this in my command from So I haven't got any error. That means my library is working fine. So in the next lecture, we are going to work with our token as well as our key so that currently we haven't utilize this in the next life, Taylor to start working on our code. We have done all the settings 5. Update Status Through Bot: Welcome back. Now, in this lecture, we are going to utilize our token as well as our keys and write our first program toe, actually update our status on Twitter. That means we are going to actually utilize our A p a. The first thing is just jump onto our authentication on here. You need to copy several chords. So all you have to do is just copy this particular court. It would be at the last here. You need to check that we are going to pass our consumer key consumer secret Archy, as well as a secret. So that means we need to pass our keys as well as our tokens. So just copy this one and let me out that in my file on my beer school, I also need to copy next two lines. Now, here, I need to utilize these four variables, so I actually need to store my keys as well as my accessed. Ogan, let me initiated this variable. Copy the values from my Twitter developer repay section. Well, that's done. So we are just utilizing Twitter authentication system. And then with this AP a object, we are going to utilize all the functionalities. Basically, we're just using this baby object to read and write data. So let me use my first command that this update status, Then there will be several attack amounts, maybe Retweet like fetch data. That means such all the tweets that process would before load on our AP object. So let me try to update our status. Let me just do one thing. Let me refresh this one. So here you can see there is no new skaters on. Let me out some content Here. Let me save my fighting Jump onto my terminal on my command. New editor, Jump onto my twitter media, Press the space? Yep, our borders working fine. So we actually have our tweet from our Twitter board. You can see this is seven second ago and this is particularly working. Fine. Let me out of print Statement that. Then let me also try to do my second tweet. All after do is just run my file again. I've got my prints statement. Let me refresh my twitter and here you can see my second readers also there. So that's how we are going to use our a p a. And I hope now you are. How basic understanding about authentication. So all we're going to do is we are going to use these keys and tokens on. Then we're using Twitter authentication system to actually create on a pay object on with the safety object. We're going to perform all the really as a less right function. That means you are going to update Streeter's. We are going to retrieve data, all the tweets, all the mentions, then retweet them like them. That would be followed in the further lectures. I hope this letter was helpful. And now you have some basic understanding. Thank you for falling this lecture. See you the next one. 6. Introduction To Auto-Reply: Hey guys, Welcome back now From this lecture we are going to work on a specific program which is going toe auto reply toe Everyone who contain a specific hashtag and they have tagged us in their status. So let me take an example. So here, from my test account, if I tweet something to unwired learning containing a specific hashtag I should get an automated reply. So if I tweet this 200 learning, we should automatically reply to this particular query since it has the specific hashtag so we can set hashtag according to ourselves, you can use hashtag and by learning we can use hashtag 100 days off fight on hashtag 100 days off court, whatever we want. So this is a basic example. What we can do is we can automate our comments so we should reply something also we should retreat this automatically as well as like this. So we are going to work on this particular program. I hope you have a clear thought. What? We are going to go in for the lectures. So from the next, let Taylor just jump onto this and start working on a program 7. Working With Timeline and Mentions: Now let's get started with our program. So let me just first clean this up. This is not required for no. And you will be using our ap object all the time. And let me come back to my twitter. I have deleted my previous board tweets and also let me get back to my test account here I would be doing 5 to 7 tweets to unwired learning which will contain different status. And some will contain hashtag and some will not. So we just need to reply hashtag only let me quickly do five friend of tweets. I would be using the text. This is a test street number one number two number three number four number wife on Regarding hashtag I would be using random to it. So now on my learning profile I should reply toe least only that means that we which contain this particular halftime heard the particular user dog me on a status with this particular hashtag. Let us start working on it before that jump on tour documentation here I need to talk about some important thing. So just going to this option Twitter epi rapper and just click on timeline matter So this documentation is really helpful for every dust we are going to do now. What method we need to use on this ap object. We need to understand through documentation. So at currently what I'm doing is I'm checking out dimensions. So I need to fetch all the mention that are done on my timeline. So all I have to do is just look for that particular method. So this is the method that we are going to use. And you can also search all the read read, start done for you. You can also search user timeline. You can also check out all the status that you contain a lot more thing, even your home timeline. So this is interesting there. Just start working without a mention. Stein, let me jump back to my via scored on hell. Let me initialize a variable called tweets. Inside this I would be story all the tweets, all the mentions that I'm getting. All I have to do is use my ap object and then use that particle a matter which is mentions underscore timeline. Now the street contain all the recent one dimensions that are done on my timeline for Now let me just bring this on, understand our result. Let me jump on my command. Problem and head. I just need to run my file. And this is the result that we are currently getting on. I know this is something hard to understand, but let us figure it out. So this is our first object. This is idee. You can see the textures at the reason why learning this is street number five. And again there are few of varieties. Ah, here I have my screen name, which is on my learning. And there are other details as well detail about my test user, their screen name. They use the name, location, their about section and lot more. So this is the complete data which I was able to fetch. This looks confusing that we do one small thing. Let me check out its type Clear up my screen on my board again. So this is a result said that means I can use my list and I can use simple index matter to fetch my result one by one to let me try to bring the first week. So this is all the information that I was able to get regarding my first tweet on here. You can see it is the only this one which is to eat no more. Fife, let me try for 2nd 1 Now here you can see this is street number four. So that means we can juggle with help off index position. What if I just want to carry with this particular text only let me use door text and then print this one? Yep. I was able to print the next only Let me try this with a second position on DSI if it playing our hashtag go north. Yep. We are able to access the street also and now we can customize it and check if this contain hash tag random to it or not. So now we are in opposition. We can capture all the tweets which mentioned my account that is admired learning And also I can get their text as a less use my end exposition toe Get particle at me that we also check what other information they contain. So E street have us on day 90. So if I want to reply to this particular tweet, I can utilise society also e street have text which we are going to use. The next thing is if I try to access this NTD as well s hashtag I can just directly see the hash tag which I'm using. So there are a lot off information regarding my user name. Also, the other user, the test user are not more information. So we are in a good position off understanding. So the next lecture let us build up our logic to print all the ID's text off tweets as well as check if that were the color tweet contain hashtag or not, I hope this letter was helpful. See you in the next one. 8. Iterate Tweets And Add Condition: Now let us continue to our previous program. So here, let me delete this one on. What I'm going to do is I'm going to a treat rate. So it contain all my tweets text ID's everything. So instead, off using my next position one by one, what I can do is I can it read all the tweets that contain inside this. So all I have to do is use my for Luke. I heard I have access to all the treats individually so I can print their i d as well s text. So let me bring them. Remember, this idea will be in the form off in on this would bean string. I just need to use a stair here. And don't forget to addio concatenation here, but we don't. My program. Yep. This is working fine. So that I'm able to access all the tweets and also their i d on. If I jump back to my crew here, you can see I currently have only five mentions. Now, the next thing we need to lose, we need to add a filter. So I need to check if this particular text contain hashtag random to it. or not, So we need to add a condition. So what? I'm going to do this. I would be adding our if statement, so I would be adding her condition. If I found this hashtag inside my text, I'm going to print new greed phone and then I would be bringing their i d as well as the text. Let me say this one and justice out you are We're doing well now we're able to face their data off only tweets which are having this particular hashtag. Now, the second thing we need to do is we need to filter this hashtag also so users can have different phone. So at currently I'm using this exact formed, which is Capital R and Capital T. So maybe someone used lower case and if I try to run this one again, see, I'm not able to find any tweet. So what I should do is I should convert this complete text into lower case. That would be much better idea then This complete week would be an a lower case. Just use the matter lower. Can we test this one again? Yep. We are able to find these two tweets now. the final strippers. We just need to reply to this particular tweet on. We have their i d on weaken do that easily. But here is a catch. What if we run this program again and again? So they are going to reply these two tweets again and again. So we need to fix them. We need to store idee that I have already replied to this particular to it. I don't need to do that. I just need to reply all the recent ones which I haven't checked out. So whatever in this case I have replied both the streets then I don't need to do anything. If I haven't replied, tow them. My board need to check that. So the less let Taylor to start working on this, we need to store the last use I d. That means the last tree that we have replied despite some confusing. But don't worry. In the next lecture will be talking about this. Thank you for falling this lecture. See you in the next one. You 9. Storing Replied Tweet ID's: Welcome back. Now we're at an interesting point to reply to. Are we so here you can see I'm easily able to access the street. Now, the next thing is, I can reply them at a one click. But the problem is, if I'm going to run this board again and again, it is going to reply them every time. So we need to solve this problem and that can be done by storing this I d. So if you check all these tweets come in a sequence so you can see the recent one previous in that previous in that previous and that and then the 1st 1 So all the tweets are coming in the sequence off their recent order. So here I can actually utilize a logic. Suppose there are five to It's done in a different spam off time. So suppose our borders running on only first Street is done. So my board is going to reply to this particular tweet since it contained the hashtag on it will store. It's I d. After next few minutes or next few hours. These two weeks are also done. So now my board will able to fetch all the three tweets, but it does not going to reply to this particular tweet. Why? Because they already have decided on my board. Know that I don't have to reply all the previous streets because they're in sequins. So my board will reply. Only do 30 now, After a few hours, these to do its are done on here. My boat will actually check only these two tweets. Why? Because it's store decided. That means my boat already know that they have replied to all the previous streets on. They will check only these two greets. So that's how we are going to utilize this particle that I d. This might sound confusing, but it is quite easy. Let us start working on it. So at all I have to do is just create a new file txt file in which will be storing that particular variety called this filers last seen. Now, this file should contain an i d. So let me use this one. So this is going to be my reference I d I just need to store this I d. So this is the idea off last treat that my board has actually seen or replying so I would be storing society. And every time if I run this file, my board will know that I have replied all the tweets before this, we could also use different data vis either SQL Light or my sequel, but that currently I just need to store i d which can be done in my txt file. So her let us start working on right, Lord off court first, I need to mention my fine name, so I would be starting that in a variable. Now what? I need Louis, I need to write to function. The 1st 1 is how to get that I d. That means how to get ideas from this. And the second function will do. Is it will store? I'd inside this file. So if I have replied, tell Hart tweet, I would be storing Assaidi inside that file on with the next run, I would be retrieving this file so I can know that I have already replied till third week. So I would write a function read, last seen hair. I need toe pass out my final him and then I would be reading that, so I would be using open and then the final name on hair. I would be using our matter, and then I would be storing this in a variable called Last Seen I d And I just need to read this and also stripped this one and convert my result in to end. And then don't forget to close your file. And I would be returning my glossy 90. This looks fine. Let me try to commend these on. Just run this function on brand out My I d Let me destined here. Yep, Working friend. Now, the next thing this we need to write a function to store our last seen I d. So I would simply create a function store last seen on here. I need to pass to arguments that is my file name. And then my idea, which I need to store that we take my find name. And then let me take a instance as fine. Right on here. I need to open my file. And I would be using right mattered. Once that is done here, I just need to use my right method over my file. Right. Just add my second argument as last tidy on inside that I need to pass last see 90 in the form off string once that is then I just need to close. And had I don't have to return anything. Remember, this function is going toe. All right? All the content that have inside this particular file. So let me do one small thing. Let me try to run this function as well. So what I'm going to do is I would be calling this function ahead. I would be passing my file on here. I need tobe us an I d and I work chain Last two digit. Let me in on this one. That's done. Let me check out my file. Yeah, it someday day. That means these two functions are working Well, now in the next lecture, we are going to utilize Thies to function and start playing with our streets. I hope this letter was helpful. See you in the next one 10. Storing-Accessing Last Seen ID: Now let me and come in this one. And for now, let me just remove this condition and start working with the logic toe work with our last see 90. Acela's are finding. Let me do one small changer. That's fine. So what I'm actually doing currently is I'm getting all the tweets on here. I just want tweets after a particle or I d remember. All these streets are in sequence. So if I passed this particularity, I should get only these four tweets. So no mention I can pass a particle Rieti, and I would be getting tweets only after that. So let me drive for this one. Let me copy this one on based it. Here, let me run this file. And now you can see I'm able to access only these two tweets. That means I'm part society and I'm getting only these two reads. So every time I replied to any comment, I just need to store that i d. And every time if I am checking for new tweets, I need to check after my previous street. So where I would be starting my last c 90 and here you also need to add a second perimeter which is called as weak mood extended so that currently we are just using tweaks line by line with the help off the street More. Even if there are multiple paragraph to eat containing links, we can utilize them. So we need to just start read, more extended. And now here we need to pass our last see 90. So what I can do is I can just simply call my function here. So dysfunction is going to return my last C 90 and then this is going to fetch all my treats on here. I can add my condition back now. This is going to look after a part of a set off creeds. Let me replace this with a lady. This is fine. Also, don't forget to wear your find name here and also here we need to update our text to full texts because now we're using extended more. So this should work. Fine. Let me try out. So I got one tweet because out off this wife to eat only the 3rd 1 contain hashtag random to it on the 1st 1 is already replying according to my bar And once my boat reply to this particular tweet. It should store Desailly. So I need to add a function inside that to store my particle A Rieti. So all after this, just call this function. And here I just need to bust a barometer fasters my fine name and then the second would be my last C 90. So I just need to pass my treat. I d So if I had done this one again, this replied to my creed. Number three Di Di would be updated here and then if I run now according to my board, they have replied to greet number three If I run this one again No two way to reply. Yeah, this is the case that we are talking about. Now I am able to fetch my last unity. That is my previous treat I d on. I can also store the latest coming to which I have replied. This is bit confusing, but now we can see a clearer we know now the only thing we need to do is we need to actually reply to this particular tweet that will be doing in the next lecture. Now we are able to store I d Now we are able to fetch Last tidy on by the next lecture will be able to reply to particular tweets. So this is going to be interesting. Thank you for following this lecture. See you in the next one. 11. Replying Tweet: you guys will come back now in this lecture, we need to talk about how to reply. Tweet. By now we are able to access street. We are able to store their ID's. That means if there are 10 tweets I have replied till six. I'm starting the idea off sixth and then with the next one, I can reply do remaining for So this wasn't some really what we have done till now. Now we have to actually reply to that We So what I will be doing now? Just remove the sprint statement And here I would be printing my ideas ballistics And then I'm going to write a function to reply so her All we have to do is just use your ap object and then use your updates. Status? Come on. So if you remember previously if I passed anything inside this that is going to a bit on my timeline. So what I need to do is I need to reply to us specifically. So suppose if I need to reply to the street number third so I would be using the society and this is the individually upending. So all I have to take care is just pass on the status what I have to print And then I need to pass my tweet idly like between my status and I could look for 100 days off court. So here we also need toe tag that particular user. So all after those just use ad rate. And then I would be using concatenation on hair. I need to pass its user name. So I would be using retort user dot screen name and then I just need to want Canton ate my message. Don't forget to add a space between your message as well as this particle. I use the name Remember I have stored i d. I guess this is work week number Tree? Yes, this one. So after that I have two more tweets which contain the same hashtag on here. You can see a mixer character here. I have used all lower case on hair. I've mixed with uppercase as well. A slower Let me finish this one and this should be fine. So now let me guess my board. So they have replied to seventh and then sixth. Let me fresh this one. I got one reply on both the status. Let me open this one Here. You can see I have my message. I also need to check for the 7th 1 and this is working fine. So now we are able to leave are coming. And if you see the last 90 you are going to see something interesting. It is matching with our six result. That means we are storing the wrong mighty And why this case is happening Because we are replying toe recently. Let me take an example if there are four tweets and all of them are done at a separate Peter off time. So what currently were fetching us? We're fitting the latest one and then the previous one and then the previous one. So that's an issue. We should reply to the previous one and then the next, then the next and then the next. And we're doing that in a wrong way. What we're currently doing were first replying to the seventh Street. Then we are replying to the Sixth Street. So in this case, the last week it replied a six. So it's stored the idea off six on. We need to reverse this case. So all after do is when were fetching the street. I just need to reverse the tweet. So all I have to add is reversed function. And now this would work. Fine. Let me go back to my third week. 904 I guess. Yep. 904 And also, let me believe these to reply, we can also do one thing. Let me just jump back to my first week itself. So if I have scored this, I d. That means it is going to reply to all these three greets. I hope they should work. Fine. Come back to my tahmeena friend. My board again? Yep. Nords 36 and seven. This is the right sequence and it should store the idea for seventh status, which is double 10 for Yep, that's fine. Let me the first this one and check out their applies. Sir, I have replied to all the three tweets. I hope now you understand about how to work with this on. You can actually play with them in the next little it. We write a function and sift all my gold inside that on after 15 2nd let me check if there is any new tweet or not. So after 15 seconds, let me check if there is any new breed or not. So we'll be adding time with our board. And it would run automatically after every 15 seconds. So we don't have to run ourselves. Thank you for falling this lecture. See you in the next one. 12. Formatting Function and Testing Bot: now in just like telling me are everything inside our function. So let me call this function as reply. Instead of printing text off status in my domina, let me bring something else. This looks much better now. I'll have to do is I have to create a condition. It should be true on it should run every time after 15 seconds. So I need to use time. So first let me import time and had I need to use my wild condition. So this will remain true forever. And then I just need to call my function which is reply once that is done, I need to wait for 15 seconds. So I just need to use my time and then sleep for 15 seconds for desk troubles that we take two seconds. So what? Actually going toe happiness. We are going to run this function. So this is going to take our tweets and then do its job. And then what is going to happen? It is going to wait for 15 seconds at currently we're using too. After do second, it is going to again run dysfunction on here. We are going to get all the tweets again. But remember, years passing last seen I d. So if I have replied, tell tweet number seven It is not going to reply them again. On it will check if there is any new treat. If there is any new to it, it is going to reply. Then again, it is going to wait for two seconds again. Come back here after two seconds. Do the same to us. So let me try to run this one on here. Have I d number seven? So that should work. Fine. Let me on my board here. You can see it is running fine on I'm not getting any error. Let me test this one on tweet one. We're learning with my tweet number it and it should reply Tweet Number it within two seconds. Hey, you can see I got my message replied, No, i d. Now if I check my tweet number eight here in my mentions, you can see I have already replied to this particular tweet. And if I try to do more greed for my desk account, it is going to reply them every time since our borders running at a sleepy it off to second that we try this with one more tweet on here. This time it should be tweet number nine that we create this one. Open my domino. Let's see. Yeah, I got a response. Jump back to my main account. You fresh this one. Tweet number nine on how you can see I have all the day's responded. So that's how we can automate our twitter Reply we can actually viewed. Read this and also like that particle estate us. So if I have replied to a tweet number nine I can read with as well as like so in the for the electricity. Just talk about this. I hope they allow you understand everything. Thank you for falling this lecture. See you in the next one. 13. Auto Retweet and Auto Like: Hey, guys, Welcome back. Now, in this quick lecture, we need to root two important tasks. The 1st 1 is free tweet. And the 2nd 1 is like that is favorite. So if you jump onto mentions, we were actually auto replying all the status which contained this hashtag what? I want us along with the auto reply. I should also retweet this and also favorite or like this there to start working on that. All you have to do is just search for favorite mentor with your A p. A. Documentation on Harry will get a create favorite mental. So if you want to check all the favorite that you have done in past, you can use a ph dot favorites. If you want to do a favorite, that is, if you want to like you have to use, create favorite, and if you want one like it, you have to use the strife every so I just need to cope with this one. And once I auto reply this coming, I just need to favorite that so I would be using my AP object and then create favorite, and here I need to pass by three Tidy, which I need to favorite. So I just need to cope in this one. Now, I also need to add Retweet solely after the issues AP object. Then you need to use tree tree and then you're to eat any. So this looks fine. And so not to second, I have actually seen this true. 15 2nd Remember, we are currently using Hobie ap A. So it has some limitation. If you're trying to run every two seconds, it is going to increase your request. So most off the commercial AP users, like companies like big professionals, incident off time in seconds. They actually take 15 minutes or 10 minutes. The best example is if you try to connect with any customer support on Twitter off all the big companies, they use some board. They use some system on the system, run an apartment off imminent five minutes or 15 minutes. So these are big giants that can afford number off requests for R A P. A. If you talk about some small user small company, they usually tend to take big gaps, so their number off requesters decrease on within one request only replied to everyone in the 15 minute off cap. I hope this was clear. So instead of 15 minutes since we're recording video, I would be using 15 seconds. Let me save this one. And here, I guess I have I d number nine. That is a last week. So what I'm going to do is I'm going to run this board, and then I'm going to create something from my testicles. So it's working, I guess. Let me jump onto my chest account here. I just need to copy some random tweet. Read this. Torn we're learning. Jump back hair. You can say Gordon Street on Ben. We need to wait. Oh, yeah. I actually got a comment. I actually got a real read. I actually got a, like, Let me do this. Once again, you can also see the previous reply. Hair come back. Air Sea than you to read. We haven't got anything yet. If I hadn't refreshed this one. Yep. We got that apply. Now you can see that I have got a reply. I got a retweet. I gotta like first let me pose this board because I have limited number of requests and hell, let me come back to my notification and check out my mentions. Now you can understand what I was talking about. I hope this was helpful. And now you can actually use or tweets and retweets. This is my testicle. These are the true tweets that we have done on hair. This one auto reply one retweet one like same for Lord, for 11 greed. And if I check out my last C 90 it has 816 We're just for our sweet number 11. That's done. We are in good shape to launch our application. That means from the loyal application on online soured. Now we can use fight on anywhere. We can use hoco. We can use digital ocean or any other platform I would prefer bite on anywhere since we can easily the prior application. So why we are deploying at application and what is going to happen after deployment? We'll be talking about that in next lecture. I hope this was helpful And now you can understand more about despite onboard. Thank you for calling the structure. See you in the next one 14. Setting-up PythonAnyWhere: Hey, guys, welcome back. Now in this selectively, I want to talk about how to deploy our Twitter board on Online's Our. Now There are two questions that you might have The 1st 1 is why we're going to deployed online. That is why we are deploying it on online server by computer on our board on command from the 2nd 1 is, is it free to reply online or do have to pay something? Jumping on to second question It is free to deploy online, but there will be a few restriction that we have to maintain. The next option that you have is you can choose any paid service off them if you want. I would be going with 31 because it is going to solve our because now, coming back to first question that why we're deploying our board online. The simple answer is no one wants to run their board 24 7 on their command from So once you close your command from once you interrupt your cord, you are going to stop your board. Basically. So what we are going to do with online server? We're just going to deploy it and it would keep running without any restriction for a few hours. For free words and interest rate to 24 hours on four paid words in it is for a while, so you don't have to touch your board again once you started and for free words, and you have to run your what once in 24 hour. So that means you don't have to play with your command trump anymore on. We'll be deploying it online. Basic step. Just jump onto by Tony where dot com and click on Staying Up on. Create a big nurse account. Quickly fill out this field, click on register and just conform your email. Once your email confirmation istan does jump on your dashboard on hair, we need to talk about two important thing. Our files on our console so console will look something like this and file system will look something like this. So what I have to do is first, I need to add booed the files so either you can use get if you are familiar with that. But there are only two files, so I don't want to stretch all the process. I can just copy base the score So all you have to do is create a new file there, select the directory your home, then user name, and then give the file name I would be using bordered by. Once you create a new file, you can paste your code here. So let me copy this one on basted here and instead of 15. For now, I would be using 60. Since I want to take care number off requests that I have with my Twitter develop Arabia. And let me see if this one no one status done. Let me jump back to my dashboard and head. I need to add another file, select Home directory than your user name. And give the fine Amos last seen or txt create a new file. And all I have to do is just store my last tweet daily. Click on Save on, Then jump back to our dash food. Now we're done with file section. Now we need to jump on console on here. We'll be downloading our tweet by library. So here all you need to do is click on bash on. You will get a terminal. So if you're someone from Mac, it would be family for you. If you are someone from windows Don't worry. It is almost same. Justo ls to make sure that you are in the right directory. So here I can see my boat. The files which is my born dot pie as a less my last seen nor txt. Now here. If I do, Pepin start to it by you will see that all the conditions are already surface fired. But you see, on online, sir word they have to buy a version 2.1. If you remember, we were using 3.7 something on. Also, let me check my bite onwards in here. Now, if you check out up by a tone origin, it is 2.7 and I was using 3.7 something now here to use five country all you have to do this, you spite on three Nash Nash version on all the MK usar might be familiar with this And now the best aboard all after is used by country and board or prior here you will see I'm getting air for my tweet bad because I don't have to reply with my words and 3.7. So just to victory in strong three By now. Here, you can see I'm not able to install my reply. There should be some reason. Read the last line on. We'll be solving this error in the next lecture. Thank you for falling this video to you in the next one. 15. Deployment Done Along Testing: Welcome back. Now let me quickly talk about the previous owner. So if I do victory in strong three by so here you will see some error. And they're also giving us how to fall this one. So all we need to do this we need to use this dash dash user before trying that I also check about this error on bite on anywhere itself on hair are the two methods to solve that ? Either I need to use user or I can create virtual environment. Let us go with the simple one All after Lewis Whip three, install user and my library name. So let me quickly implement that press. Enter and let me check out My result. This works fine. Let me see if I'm same directory now we can on our board. All I have to do is fight country board dot by it's working. I think we should add something at dined off our court. Maybe some print message so we can keep getting update. Let me interrupt this one. Go back to my dash food and let me out up in statement. It then saved this one open my controller trying to run my board again. So what's going to happen? Call dysfunction. Wait for success again then. Prince Statement. Hera got one working. I need to wait for 60 seconds again. Till then, let me also do one thing. Let me do a few test suites. I've done treat number Well, I can go toward three tweets still Then this one is riddled. Hashtag let me jump back to my control. I have done three treats Do with has stock one with without hashtag I think 60 seconds about idea while recording a lecture here you can check I got two replies and then now it is waiting for 62nd again if I check my Twitter mentions here I go to tweets which have coming Retweet like on fourth Street number 13 We haven't done anything because it is not having hashtag now you can leave this control as it is. All you have to do is just close your Dobbs on this is going toe on whenever you want to check again just with it. Fight on anywhere Just open your Bascomb tool and you will see it is still running. So if you want to automate your director, just use a time for 10 or 15 minutes and you're good to go for 24 hours easily. Just come back after 24 hour. You might see some interruption like this currently. Views controlled. Let's see. But you might see some interruption like this because of the free version. All you have to do is just a new command fight, country board or pyre. And you're good to go for next 24 hour. And if you are someone who is using paid words in, you can just run your board and forward about a. It is going to run forever. I hope this was helpful. Now you don't have to run your board all the time on your command. From once you finish your board development, you can just post it online. I hope you actually heard some good decision and you can see we just done some random to eat 70 tweets. I hope this collectibles helpful. See you in the next one. You 16. Auto Retweet To Particular Hashtag: Hey guys, Welcome back Now, this lecture is going to be interesting because we're going to do something different. Have you ever tried to tweet something on Twitter with some trending hashtag or maybe using 100 days off court? Or maybe some popular hashtag you might realize that you get automatic likes automatically to it. Even if you write some dumb straight us here. If you see my notification, I used good luck for hashtag 100 days off. Good Here you can say go to Retweets. The 1st 1 is from our Twitter board and the 2nd 1 is also from aboard for a second. Let me check this 100 days off. Good. So all you have to do is to search for 100 days off court on just jump onto latest here you will see there are a number of students that are already working on this. But if I jump onto their status and check out there like this like is also from board which is 100 days off court if I check the 2nd 1 this is all sort weight aboard. We need to talk about this automation also. So how they're working and what is the procedure there, they're falling. So what we're going to do in this lecturers, we are going to take a particular hashtag and fetch all the latest streets on Retweet and like them, like these board so you can use any hashtag. I would be using hundreds off court. You can use hashtag anything. Maybe one plus seven, maybe one plus it maybe anything else, but that must have enough tree. So if I try to do bite on here, you can see there are enough to eat right now. And we can also retweet and like them. You can see there is already one Greek return like this must be a board itself. So we'll be talking about this now Let me jump onto my via scored here. I have created a new file called Search for Dark by Let me copy my authorization cord on with the previous port. What we were doing is we were using a P object and then we were collecting all the mentions on our time line and then storing it through tweets. Nine. This what will be using our tweet by and then we'll be using a coarser So if you jump over the documentation here. So what we're going to do is we are going to use three by object and then Carson matter. Let me jump onto my Via scored on give your demo. Just used to buy coarser on here. You need to pass two items first will be your a p a door search and the second will be your hashtag. So I would be falling 100 days off court. So we need to bust this particular hashtag. Once that is done, I need to define number of items. So how many tweets I need to fetch if you jump onto your search? So if I talk about two items 400 days off court, it would read Read this and then this. So I need to take care off that for initial test, I would be taking number s three. This works fine. Now our tweet contain all the tweets from that particle. A sausage. Now the process remain the same. I have to a trade through them and between. So I have to do is use a for loop treat inside my treats. And here I would be using my tweet. All have to do is use my create favorite or retweet mental. This looks fine to me. If you still have confusion for this, I would recommend you to jump onto the documentation and such about coarser tutorial. Harry will understand a lot about this. You will understand the old way as well as the new way. So if you face any difficulty with this sport particularly, I would recommend you to check out this culture to Doria. I hope this looks fine. Let me run my board here. So I got an error that I have already. If he created this item on, I need to fix that. But first, let me check out my profile. So here I have done retweet to two items. And to solve this problem, I have to use try and catch flock. So all we need to do is implement error handling that we were doing in the next lecture. I hope now you understand about this. All we have to do is take our hashtag number of tweets that we need to re tweet as well. It's like and then simply write a function will be completing the sport in the next lecture . Thank you for falling this lecture. See you in the next one 17. Implementing Error Handling And Testing Bot: Welcome back Now in this lecture we need to talk about our error. So the first basic thing that we need to follow is try and accept blow. So here, let me for start try before my retweet and then I should add I accept on instead off any random exception I can use to eat by dark. And then here you can see I have ah, error, which is called creep in. I should take it as e and let me bring this exception. So I just need to use e on here. You will get an option Reason This is much better. You can also use I stopped attrition. The next thing I would suggest as abort user once you do any DIY treat anything else, just wait for a few seconds if you are going to do retweet and like every second so this is going to affect your outcome. So I would suggest just give away time. So here let me import time. So all after the issues time sleep and then give five seconds. And what if we create a function and move everything inside that Let me call this function . This looks fine to me Let me out of brain statement here. Retweet done. Things looks fine but we don't my board again Here you can see I have done a retweet on. Then it should be invading Peter for five seconds then head. I got an error message on Harry. Done. One more tweet. So our current limiters three and we have done to breeds with one another. Let me finish this one here. So here I have done to Retweets. Let me also add asleep time here and changing toe to second on increase my limit for 10 tweets on my board again. The 1st 1 is done. 2nd 1 is done 3rd 1 is done so you can see That's how we are falling Because we recently done these three tweets. So they are in our list on here. You can see I have done all the retweets automatically. Now if you want to test this board, you can use different other hashtag on If you want combination off more than one hashtag All you have to do is use a couple. So just pass your for study which is your first hashtag and then your second hashtag. So then it will only follow all the streets which have both off these hashtag that we knew the steam and one more change you can do is insert off item. You can use page numbers. So if you do page and then pass on item as one, it will fetch 20 tweets on. This can change according to my documentation. So one page is equals to 20 tweets. Currently it might change in future. You need to check out their documentation. So you have to do is use pages on. If you are talking about 10 pages, it would be close to 200 tweets. If you're going with one, it will be equal Su 20. So these are a few basics things that you can play with hashtag with items with big numbers and all other thing. But my main motive was to make you understand regarding fight on auto mission regarding trade aboard. Now, by the end of the scores, you are easily ableto heat. We update your status like such a vote. Anything? Read with them? Check out your timeline, check out your mention or to reply and everything. I would suggest one strong thing. Just jump onto this documentation such about anything that you want and you can basically play with Twitter. I hope this course will send full. Thank you for falling this lecture. See you in the next one.