![]() To send an SMS message from Python, we’ll call the Textbelt web API with the help of the request package. It won’t affect your system’s Python installation or your other Python projects. You can then install whatever package, even a specific version of a package, just for the project you work on. I highly recommend using a separate Python virtual environment for each of your Python projects. I named it the same as the project and located it in subdirectory venv of my home directory.Select the option to create a new virtual environment for the project and specify its location.I called the project smsdemo and located it in subdirectory PycharmProjects of my home directory.Select the location and name of the project.Create a new project with virtual environment It includes the creation of the virtual environment and installing the requirements from PyPi. This section covers the setup of our P圜harm project called smsdemo. This previously published article explains in more detail how and when to use a Python Virtual Environment. To not pollute the global Python environment on your Linux system, we will use a Python virtual environment. We’ll be installing a dependency from the Python Package Index (PyPi). For details, refer to the article about installing the P圜harm Community Edition as a Flatpak from Flathub. That makes it easier to follow along with this article. I recommend installing the free P圜harm Community Edition. Regular readers of this blog know that I prefer P圜harm for Python development. Therefore you just need a Linux based PC with desktop environment, to complete the steps outlined in this article. What do you needĪll Linux desktop distributions come with Python preinstalled. Note that I am not affiliated with Textbelt. This article teaches you how to send an SMS from Python for free, using the Textbelt web API. After figuring out how to send an SMS from Python, I figured: “Why not share what I learned”. Therefore, you could use this approach at no additional cost. For server monitoring you typically do not expect daily issues. Best of all, Textbelt allows you to send one SMS from Python for free, each day. ![]() No need to create an account, simply prepay with PayPal. I found a really nice one called Textbelt. That left me with one more question: “How to send an SMS message using Python”? You need a third-party web API for this. Multiple options exist, such as a WhatsApp, a Telegram or an SMS message. Upon detection of a page title mismatch, I wanted to receive a notification on my phone. It loads the HTML of the front page, extracts the page title and compares it with the title that I expect. The Python program runs periodically as a Cron-job on another server. It got me wondering though: “How can I be informed about similar issues”? I decided on writing a quick Python program for monitoring purposes. Digging a bit deeper, I concluded that the new plugin caused the problem. I quickly reverted back to the latest backup to limit downtime. After about a week, I noticed that all of a sudden web pages no longer loaded properly. Not too long ago I experimented with a different WordPress caching plugin for this site. Great for server monitoring purposes, where you do not expect issue on a regular basis. Textbelt allows you to send one SMS for free every day. ![]() The demonstrated Python code to send an SMS, builds on the Textbelt web API. Simply copy-paste the function into your own Python program and voilà, you are all set. Curious about how you can send an SMS message from Python for free? This article presents a ready-made Python function to send an SMS message.
0 Comments
Leave a Reply. |