Sometimes I wish I can find my old post, refer to it and link it to my current post.
Searching for old posts using Hive's front end is hard, slow and almost impossible. Using Hive.blog and eSteem App was suppose to be the simplest option. After scrolling down to view posts older than 2 months it seems to get stuck. If you can see posts older than 2 months after waiting for few minutes, consider yourself lucky.
Since I can't use the frontend and copy and pasting. So I have to use Hive library to program something to do the job.
According to hiveprojects.io there are currently 5 libraries we can use to communicate with the Hive Blockchain:
After a few moment reading through 4 of the libraries I choose only Python because it is the easiest.
Python is so easy, all you need to know is the keywords like using the command line. It is easy, so if you want to learn more can go to https://www.learnpython.org/ and learn it for FREE. You can search it on YouTube if you prefer to learn by watching videos.
Finally, out of all the four I choose BEEM.
Before you can Install Beem, you need to have python because it is a python library.
You can easily install Beem with pip
pip install beem
If you are successful in isntalling the library, you can start coding.
Since I am having problem with latest version of Python. I am using Anaconda Python Distro to install Beem and all the library I need.
After you installed Anaconda, open the Anaconda Powershell.
Once you launched the Powershell, type commands line like below:
conda config --add channels conda-forge
That command was to add conda-forge to your channels so you can install beem. Once the conda-forge channel has been enabled, beem can be installed with:
conda install beem
Thats all for the installation, but if you want more information on installing in different ways, please refer to the official installation manual.
I will try to explain the code I made, which can be view directly in my github repository.
First, you need to create a new python file. After you create a new python file, insert the library needed on top.
from beem.account import Account
from beem.comment import Comment
from beem.exceptions import ContentDoesNotExistsException
Replace the username in the code with your Hive username.
account = Account(username)
c_list = {} # list of the post
count = 0
A line to open or create the markdown file to insert the post links. Must have the utf-8 encoding because without that the file can only accept ascii.
f = open("hivepostlist.md",'w',encoding="utf-8")
The code below were literally taken from @holger80 example in the official BEEM docs on displaying of all posts. Then added some more properties in order to write a list of links in a Markdown file.
for c in map(Comment, account.history(only_ops=["comment"])):
if c.permlink in c_list:
continue
try:
c.refresh()
except ContentDoesNotExistsException:
continue
c_list[c.permlink] = 1
if not c.is_comment():
title = ""
title = title.join(c.title.splitlines()) # Settled the titles with newline problem
count +=1
print(str(count) + title)
f.write(str(count) + ". [" + title + "]" +
"(" +"https://hive.blog/"+
c.parent_permlink + "/@"+username+"/"+
c.permlink + ")" + "\n")
f.close()
When you run the python file with python yourfilename.py you will generate a markdown file like the picture below which is available in my github repository.
If you want to just download and try the code, just get the file in my github repository.
Next, I will update a few things in the code like adding a progress bar and timer just to measure how long does it take to list down all the posts.
Thank you @holger80 for the cool library and thank you for reading.
Please, follow, upvote and comment below.