ARInnovate is a specialised consulting firm providing organisations with bespoke software development and cyber security services.

CONTACTS
recroot blog 20 1024x594 1 - AR Innovations

Python is a cool language. It is one language where you can do so much with very little. With its extensive use cases, versatility and the fact that it is easy to learn and use, makes it the favourite language of the coders prodigy.

Amongst the various use cases, one of the applications of Python is in automation, for which it is very popular. Even if not including Machine learning(for which it is extensively used), Python still can be used to automate the daily tasks that you do manually.

This post is solely dedicated towards automation with Python. This article is a compilation of some of the amazing libraries using which, you can automate your Whatsapp, emails, mouse clicking, windows management to mention a few and lots more.

Get pumped up for getting all the redundant daily tasks automated.

1. PyAutoGUI

This is a killer library that could automate literally anything. From whatsapp to Instagram to automating your games. The use cases of this library are endless.

To put Simply, PyAutoGUI as the name suggests, lets your Python script control your GUI elements like the mouse and the keyboard of your pc. With this library you can automate the manual interaction with the operating system and other applications. The best thing is that it works with all of the popular operating systems, like windows, mac os and linux.

Some of the notable features of PyAutoGUI are:

  1. Controlling the mouse, clicking on various windows of your application and operating systems.
  2. Sending your keyboard keystrokes to applications. You can automatically type in your search query without the need for you interviewing.
  3. You can give an image of something, for eg a button or any element and it will find that object and return the location, allowing you to perform desired action.
  4. Control windows of applications. Actions such as moving, resizing and maximising of windows or even closing it. (But this is currently limited to  windows only).

Some of cool things you can do with this library areas follows:

  1. Make a Whatsapp, Instagram or a Facebook Bot
  2. Automate games
  3. Automate form filling
  4. Automatic opening of certain apps. For eg playing your favourite spotify playlist

2. Selenium

Selenium is one of the most well-known and used open-source test automation software.

Originally it was developed for automating web applications for testing purposes, as you could replicate certain conditions and test how your app performs.

But it is not limited to just testing purposes, soon it started to be used to automate web based administration tasks, for e.g. web scraping, automating web navigation.

With this library people have created really useful and cool projects that would blow your mind.

Selenium comes with 3 options:

  1. Selenium web driver
  2. Selenium IDE
  3. Selenium Grid

Selenium is a big software with lots of horsepower under its hood. It can be used to automate the testing part of your applications with cross platform support.

One of its sub section Selenium webdriver, is a really good alternative for the counterpart used for web scraping, named BeautifulSoup.

Selenium webdriver is a collection of open APIs that enable users to interact with any modern web browser and automate user activities with those browsers.

The pros of selenium is that it can be used for clicking and navigation on web pages. BeautifulSoup has limited functionality and fails to interact with javascript.

With selenium you could mimic the entire human and web browser interaction, one would not be able to distinguish if the person on the other side is a human or selenium script.

Some of the use cases of selenium web driver:

  1. Automated web testing
  2. Web scraping dynamic content using Selenium
  3. Creating bots for all the popular social networking apps
  4. Bulk downloading of pictures and videos

3. Requests

To work with an API you need to send requests to a server and then read the responses. If you have ever tried making an http request using Python, you would know how painstaking it is to make a HTTPrequest.

And it is very inefficient to just spend loads of time tweaking the request, whereas you could have spent that time doing more productive stuff. It is never a good idea to reinvent the wheel.

The best way to interact with an API or send HTTP requests, is to use the request library. It has now become a coding standard to use this library.

As the developer says on their official website, “Requests is an elegant and simple HTTP library for Python, built for human beings.”

As promised, requests library allows you to send HTTP requests, without the need for manual labour and endless errors. You don’t have to worry about the type of request, encodings and more. Just a one liner will get the work done for you!

request= request.get(“https://www.google.com/”)

4. PDFMiner and PyPDF2

You can use python to automate the boring task of cerating, manipulating and editing a pdf file. With the two libraries named, PDFMiner and PyPDF2, you could do endless things with your pdfs.

PDFMiner

PDFMiner is tool mainly used for extraction of information from pdf documents. As you might know pdf is stored in a completely different format in comparison to word or text formats. Therefore extraction of text from pdf is not simple. It very soon becomes difficult with all the variations present in PDF files.

This library comes also with a pdf parser that can be used for purposes other than text analysis. You can read more about it one their official page.

PyPDF2

PyPDF2 comes with rich features that could cater all your pdf manipulation needs.

Some of the notable features of pypdf 2 are as follows:

  1. Extraction of document information( but it is not as extensive as PDFMiner)
  2. Splitting documents
  3. Merging documents
  4. Cropping pages
  5. Merging multiple pages into a single page
  6. Encrypting and decrypting PDF files

By using the extensive capabilities of both the libraries mentioned above, you can do anything with your PDFs. From creating, editing to extraction and organising data.

5. PyWhatKit

This is one of the coolest and easiest to use libraries in this list. With this library you could automate whatsapp messages, emails, with just a few lines of codes.

Not only this, this library has some really other cool features. With currently over 300k downloads, this library is not losing its momentum of rapid growth.

Features

  • Sending Message to a WhatsApp Group or Contact
  • Sending Image to a WhatsApp Group or Contact
  • Converting an Image to ASCII Art
  • Converting a String to Handwriting
  • Playing YouTube Videos
  • Sending Mails with HTML Code

Conclusion


In this post we looked at 5 Python libraries, using which you could automate some of the most redundant tasks that you do daily. Not only is automation with Python cool, but also it is practical, it saves a lot of your time.

There are several other libraries that were not possible to be included in this most, as it would have gotten very long. If you know of some that I have missed, mention it down below.

Thank you for sticking till the end, have a good time automating the boring stuff.

Author

admin

Leave a comment

Your email address will not be published. Required fields are marked *