Python In The Shell: A Way To Gather Steemit User Info – Post #106
The Python Modules
Lines 1 to 9 are the lines of codes that python uses to collect its modules (or tools) so that it can effectively execute whatever routines we want it to do do.
1 #!/usr/bin/python3.6
2
3 ###MODULES
4 from steem import Steem
5 import sys, os
6 import json
7 import shutil
8 import requests
9 from bs4 import BeautifulSoup as soup
We will briefly go over each one.
The steem module is the one responsible for any queries on the STEEMIT blockchain data. We need such data for some areas of our info gathering as far as one specific account is concerned. Very handy if this need arises.
The os and sys modules are very much useful if we want python to go back to the linux shell for any stable and mature commands, examples of which are sed, grep, tail, etc etc. We need such as well depending on the situation of course and as the need arise.
The json module will be used by python to format any JSON file or stream to whatever data extraction we like. It so happens that the STEEMIT blockchain file is formatted in JSON so this is very important for us.
The shutil module is a python module for manipulating files and folders the pure python way. We can do file and folder manipulations using the os module but it is always desirable to do things direct python, so we will have a choice here as far as files and folders are concerned.
The requests module is the one python uses to examine any HTML data, and of course, we already know that web URLs are in html, and if we want to examine such data, then we need an html tool.
The BeautifulSoup module is the one python uses to scrape (crawl or manipulate) a web URL. As long as something is displayed in your web browser, this module is designed to extract information on the site as seen by the browser.
Python is full of modules according to the needs of a programmer, one thing I really liked about it. It is like opening a toolbox if one is a carpenter, and all you need is already there, just pick the one you need for the day.
“Screwdriver For Screws Hammer For Nails….. But Safe To Say Python For Everything.”