Hello programmers, welcome to our FUN CODE LAB.Here we always do some interesting stuffs with code and have some fun withthat so today we are going to create a Pythonscript that can automatically comment on any Facebook post like this. But makesure that you are not using the script to spam anyone or harm anyonethis is just for fun and fully educational purpose. 

okay let's get started.At first we have to set up our environment and I'm going to do it onUbuntu but I will instruct you how to do it on Windows as well, So first of all we have toinstalle Python and pip on our system for that just type "sudo apt-get installPython3"to install Python and for Windows user you have to download Python exefile from their site python.org and install it on your system. whileinstalling make sure that you checked the add to path check box to ensure thatpython is available on your whole system and to install pip on ubuntu just type sudoapt-get install python3-pip and the pip will be installed. 

In my systempython and pip is already installed that's why we are getting a messagethat the package is already installed but on your system, you will getdifferent message and on windows you don't have to install it separatelybecause it come alongside with the Python package. ok the last step of oursetup is installing a python module called pyautogui. so to install thismodule you have to just type "pip install pyautogui", this command is sameas Ubuntu and Windows so if you are on Windows just open your command promptand type this command. 

In ubuntu the process is slightly different we have toinstall additional three dependencies for this module so that wehave to install scrot, python3-tk and python3-dev For this we have to install thatdependencies. Just type "sudo apt-get install scrot python3-tk python3-dev" and this may install the three additional dependencies in your system, okay now the dependencies are fulfilled and we have to put in the module now for thatjust type "pip install pyautogui" this will install the pyautogui module onyour system. okay our environment setup is complete now. 

Now we are going towrite our script. Before writing the script open your Facebook account just because weare going to comment on Facebook post and that's why you have to open ourFacebook account first and then we are going to write this script. okay let'sopen our Facebook account here choose any Facebook post where you want to autocomment, let's say I am going to comment on this post okay. Now keep that tab openand open your code editor to write your script. Here I am going to use my VS codebut you can use any code editor you are comfortable with. 

Now create a new fileand let's call it autocomment.py now let's write the script. In this script weneed to module called pyautogui and time so let us import them. Now we aregoing to create an array that contains the comments that our script willautomatically comment on the Facebook post one important note that don't usethe same message and comment it again in again because that's why your account willbe blocked by Facebook. so use some different messages to comment onFacebook. 

For this now I am going to create an array that's contain differentmessages and our script will comment that messages on the Facebook post.okay now our array of comments is ready and here we are going to pause ourscript for 5 second it gives us a time to go to Facebook and choose any postwhere you want to auto comment. For this we are going to use the time module andin the time module we have a function called sleep and we're going to use thatfunction to pause the execution of our script for 5 second. okafter this five-second pause we are going to create a for loop that willkeep commenting on the post that we will choose. so for this we're just going tocreate a for loop right now. 

Here I type i in range 10 that means our script isgoing to comment just 10 comments on the Facebook post. if you want to increase thenumber then just change that 10 to any number you want.now we are going to write on the comment box. For that we are going to use pyautogui module and the typeWrite function. so for this just type pyautogui.typeWrite and here we have to put the message that we want to type. here we aregoing to use the comments array, on the index field type i%7 that'sbecause in the comments array we have seven content and we are going toshuffling them one by one. after writing your comment we now have to press theenter to post your comment for that we're now going to press the enter withthe help of typeWrite function after that we are going to pause our loop for athree second after each comment because if you do it too fast then Facebook willgoing to block your account so don't be too rush and do it slowly for that weare again going to use the time module and sleep function for two seconds ofpause and your script is done .okay now execute this script and let's seehow it's going to work. for that open your terminal I am going to use theinbuilt terminal of vs code but you can use the external terminal as well, itwill be same for both now just to minimize this window andopen your Facebook, now we are going to execute our script so for that this typepython3 space your script name and if your windows you don't have to put the 3at last so you have to just type python space your script name. 

Ok now I am goingto write python3 autocomment.py and after pressing Enter youhave five seconds to go to the Facebook tab and choose any post where you want tocomment, ok now I want to comment on this post for this just click on the commentsection and wait for 5 seconds. now you can see here that our script is automaticallycommenting on this post and it's just typing the comments we have specified inour comments array so that's how you can use your Python script to automaticallycomment on any Facebook post but I am repeatingagain don't harm anyone or spam anyone with this script just use it for fun orfor educational purpose and that's it for this video if you have any doubtthen query then comment below and also if you have any interesting idea that wecan do in  our FUN CODE LAB then also comment it on the comment section and ifyou enjoy this video like this video and also subscribe.....