All you need to know is we have created an instance of Chrome using the function webdriver.Chrome(). Understanding this part of the code in more depth is out of the scope of this article. If you run this code it should open a tab in Chrome. We will be doing this with the following code: web_browser = webdriver.Chrome() So the first step when I want to message someone on my laptop with WhatsApp is to open Chrome. Just as if we were doing it manually with our mouse and keyboard. Essentially in this program we will be informing the computer where to press, what to input, and how. The first step of any program like this is to connect to your browser so you can control it. Lastly pyperclip is used to allow for copying and pasting and clipboard type functions. The time module is for buffering just in case. The importing of Keys is essentially importing the keyboard to tell the computer which keys to hit. The next line is for the expected conditions to be met with the WebDriverWait function. The webDriverWait allows for our program to wait for the webpage to be loaded before moving forward in the code. The next statement is required to allow for searching of elements by a certain property. The first line is needed to bring in the webdriver extension, this allows for our program to open and connect to Chrome. These are all of the import statements you need for the following program. If the following doesn't make sense yet, come back to this section after so you can see how these lines were used. The Import Statements from selenium import webdriverįrom import Byįrom import WebDriverWaitįrom import expected_conditions as ECįrom import Keys Open the command prompt and enter the following command: pip install seleniumĤ. The installation process for selenium is simple, you open the command prompt by searching up "cmd" on your computer. Selenium is a great program for working with automation and web applications, we will be using it for these exact purposes. If you get stuck here, here is a video of how to download ChromeDriver for windows and for Mac. Once downloaded we will move this zip file and extract it into the folder we have created. If you are on windows the 32bit link works regardless. Then you will choose the appropriate link according to your system. On the page choose the appropriate link for your Chrome version. The first 3rd party application we will be using is called ChromeDriver You can download the program here. In order to do this, we will be using some 3rd party applications like Selenium and ChromeDriverto connect our code to the web. If you want to know how to send a bulk message with WhatsApp then we need to make our own program and use functions to make it customizable. Or if you just want to make the porgram quick and utilize it's functions. Using a third party app that has already created code can be a good way to learn if you look at how that code works. That is all that is needed, but if you want to learn how to do this and make a more customizable program, keep reading. The first argument will be the phone number you would like to send to, then the message, followed by the time in 24 hours, and lastly the minutes of the time you want the message to send at. The next line calls upon the sendwhatmsg function, which sends the message on WhatsApp. The first line imports the PyWhatKit module. ndwhatmsg('+phone number', "Hello automated world", 14, 20) Copy the command depending on your system. If you do get stuck with the command line installation here is the link to there site where they go more in depth click here. I always enjoy doing my installations through the command prompt, but there is another way. First we will be making a folder and calling it "bulk_automate_whatsapp" Next we will make our python file called "whatsapp.py" or whatever you would like to name it. We will be going over how to install PyWhatKit next, the other two you should search how to videos for installing if not already installed. For this article we will need python, an IDE (I use Pycharm), and PyWhatKit. This article is meant for all levels I will be going over two ways to do this.Īs always, the most important part of any program is the set up and ensuring you have everything required to get started. Over the course of this article, you will be learning how to automate the sending of bulk messages with WhatsApp! A basic way which only uses 2 lines of code and a complete program so you can understand this process.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |