3

7 Python Libraries to Make Automation Easy

 3 years ago
source link: https://medium.com/quick-code/7-python-libraries-to-make-automation-easy-78103087d020
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Requests

Usually, when you want to automate something, you might come across APIs. Requests is a simple to use HTTP library for Python library that allows you to make requests and interact with APIs.

To replicate a request easily, I open the Network tab in Google Chrome, select the request I want to repeat, and click Copy as cURL. And then, I paste the cURL command to some converter and get the Python code I need.

Pro tip: if you want to run your automation without keeping your laptop on all the time, one easy way is using Github actions.

APScheduler

When I make some API request, I usually want to run it periodically, like every fifteen minutes or so. For this kind of case, I use a package called Advanced Python Scheduler. The library has really nice documentation, which will allow you to take it into use very fast. In fact, I used APScheduler when building a screenshot automation using Python and Google Calendar project.

CSV stands for comma-separated values and is one of the most common formats for spreadsheets. This library can be handy when you try to fill your tax papers, do some basic accounting, process data, and so on. There’re many possibilities, and the format allows you to open the file on programs like Excel, Google Sheets, etc.

Watchdog

How often do you want to observe some folder and do action based on that? Watchdog is a module that allows us to watch the file system. Got messy Desktop? Use watchdog.

Selenium, Beautiful Soup, Scrapy

It’s hard to imagine automation without web scraping. For example, let’s say you want to keep track of prices on Amazon or automate ordering food from a restaurant. For these kind of cases, it might be better to use web scraping tools. Since Selenium is also used for test automation, you can use it for doing actions on websites such as filling forms, clicking buttons, etc. Beautiful Soup is good for simple projects. Scrapy might seem a bit complex to learn but keep in mind that it suits complex projects and is significantly faster. So do your research and find which one fits your needs.

Twilio

Let’s say you build automation to track prices. How would you get informed when prices are at the level that you want them to be? In these kinds of cases, you can use the Twilio library, which allows sending text messages and making calls.

Random User Agent

Last interesting library for automation is called Random User Agent. This library allows you to add random user agents to your requests. Using random user agents should help a bit so that you don’t get caught while scraping data or sending many requests.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK