I.T. Spices The LINUX Way

Python In The Shell: A Way To Gather Steemit User Info – Post #107

The TEMP Directory And The Steem Blockchain Query

10
11 ###MAKE TEMP DIR
12 tempdir = '/dev/shm/steemblogs'
13 shutil.rmtree(tempdir, ignore_errors=True)
14 os.mkdir(tempdir)

Lines 10 to 14 will create the temporary directory where all files will be placed in every run of this script. Before it will create such folder, it will delete said folder firstly.

It is worth noting that in deleting the temp folder, we instructed python to ignore errors so that the script will not exit abnormally.

This is like telling python that delete the folder whether it is there or not, and do not choke on me please if the said folder is not present, just move on.


15
16 ###NODE SOURCE
17 s = Steem(nodes=["https://api.steemit.com"])
18 ###GET ALL BLOGS FROM AUTHOR
19 all = s.get_blog(sys.argv[1], entry_id=-1, limit=500)

Lines 15 to 19 will fetch all of the posts of any given author, any steemit account as given for this matter.

Line 17 defines which steemit address the script will go to to query such, do rememebr that this address is an api, a gateway of sorts, so that any user from the web can query anything on the STEEMIT blockchain.

Line 19 is the exact python command to fetch the blogs of a user in the form s.get_blogs(). This line simply tells us the account name as given by the first argument, the entry_id being negative 1 means that we start from the very first blog up to the limit of 500 counts.

More on line 19, so if a certain user has more than 500 posts, then we need to execute this line by as much, divisible by 500, so that we can get all posts.

It is worth noting that the main purpose of line 19 is not really the full blogs as we intend to get it another way (by crawling), its main purpose is only to get the full list of the upvoters because the STEEMIT website for any blog is only limited to 20 upvoters.

What if the upvoters are more than 20? So we deploy the steem module here, not the crawling modules which will be explained in later posts.

One way I can describe python really is a chef that do multiple tasks at a time.

Can you imagine working alone for a task that needs, say, 5 workers?


“How We Live Is More Important; We All Die Anyway.”