This tutorial is about writing a post with beem. You learned in my last post how to install beem. Let's use it now.
At first we need to store the posting key (safely encrypted in a sqlite wallet):
At first we need a wallet (This step is only necessary once):
beempy createwallet --wipe
Now we can check, if the wallet was sucessfully created:
beempy walletinfo
For publishing a post, we need to store the posting key:
beempy addkey
We can check if this has worked by:
beempy listaccounts
I will use beembot for testing, so I added the posting key of beembot:
As we do not wan't to write down our wallet password, we will temporarily store it as environment variable for windows:
set UNLOCK=yourpassword
and for linux:
export UNLOCK='yourpassword'
We can check if this had worked by:
beempy walletinfo --test-unlock
A similar table should be displayed now (after setting UNLOCK inside the terminal) without entering a password:
At first, I used ImageUploader for uploading a png image to steemit:
img_link = image_uploader.upload(image_path, author, image_name="beem-logo.png")
image_path contains an image filename, author is a account (its posting key needs to be stored).
The function returns a dict, img_link["url"] contains the url, which can be used inside the post for displaying the uploaded image.
Then I created all necessary variables and entered them into the post function of steem:
The following script was used to create an example post:
#!/usr/bin/python
from beem.imageuploader import ImageUploader
from beem import Steem
if __name__ == "__main__":
stm = Steem()
author = "beembot"
image_path = "beem-logo.png"
image_uploader = ImageUploader(steem_instance=stm)
img_link = image_uploader.upload(image_path, author, image_name="beem-logo.png")
title = "Example for writing a post with beem"
body = "This is an example for a post, created with beem by @beembot."\
"We will also upload an image:"\
"%s" % img_link["url"]
parse_body = True
self_vote = False
tags = ["python", "test", "this", "is", "just", "a", "post"]
stm.post(title, body, author=author, tags=tags, parse_body=parse_body, self_vote=self_vote)
Save your python script now as file (I choose write_post_with_image.py) and run it with python:
python write_post_with_image.py
Remember to set the UNLOCK variable at first. Otherwise you will get a beem.exceptions.WalletLocked exception.