Anaconda 安装 beem,开发 python版本的 steem 机器人
beem的好处是,可以自动寻找可用的 steem 服务器节点,大多数时候,不用担心网络访问的问题.
Anaconda的好处是,跨平台管理 python开发环境, 不管你是windows开发者,还是linux/mac的开发者,基本操作都差不多.
本帖以苹果电脑为例(windows/linux未验证).
开源的Python包管理器 anaconda :Anaconda是一个开源的Python发行版本,包含conda、Python、numpy、pandas等上百个科学包及依赖包,下载文件比较大(> 500 MB),如需节省带宽或存储空间,可用Miniconda这个小发行版(仅包含conda和 Python),再根据需要单独安装需要的包。
beem:是 steem 的一个非官方python库,从 python-bitshares ,包含一个好用的 命令行工具 beempy。
MAC 安装 Anaconda3
beem工具的运行环境要求 Anaconda3 (Python3) ,如果 Anaconda 官方下载太慢,可用清华大学镜像:
$ cd ~
$ wget https://repo.anaconda.com/archive/Anaconda3-2019.10-MacOSX-x86_64.sh
$ bash Anaconda3-2019.10-MacOSX-x86_64.sh
$ source ~/.bash_profile
$ conda activate
(base) ~$ python -V
(base) ~$ pip -V
退出Anaconda3环境:(base) ~$ conda deactivate
Anaconda3 安装 beem
$ cd ~
$ conda activate
(base) ~$ conda config --add channels conda-forge
(base) ~$ conda install beem
(base) ~$ conda install cryptography
使用 beempy
使用最快的节点:$ beempy pingnode --sort
创建本地钱包密码:$ beempy createwallet
查看钱包信息:$ $ beempy walletinfo
+-----------------------+--------------------------------------------+
| Key | Value |
+-----------------------+--------------------------------------------+
| created | True |
| locked | True |
| Number of stored keys | 0 |
| sql-file | /home/xy/.local/share/beem/beem.sqlite |
| password_storage | environment |
| UNLOCK env set | no |
| keyring installed | yes |
+-----------------------+--------------------------------------------+
修改本地钱包密码:$ beempy changewalletpassphrase
添加steem账号:$ beempy addkey
删除steem账号:beempy delkey [OPTIONS] public_key
查看钱包内的steem账号:$ beempy listaccounts
+-----------+---------+-------------------------------------------------------+
| Name | Type | Available Key |
+-----------+---------+-------------------------------------------------------+
| maxxxxnk | active | STMxxxxxx9dvE |
| manbbbbnk | posting | STM87YzixbssssEDKXfU |
+-----------+---------+-------------------------------------------------------+
查询余额:$ beempy balance maxxxxnk manbbbbnk
示范一个当前最新发帖的机器人(demo.py):
from __future__ import print_function
import sys
from datetime import timedelta
import time
import io
from beem.blockchain import Blockchain
from beem.utils import parse_time
if __name__ == "__main__":
blockchain = Blockchain()
for vote in blockchain.stream(opNames=["comment"]):
print(vote)
执行程序:python demo.py
打印出的信息:
{'type': 'comment', 'parent_author': 'munaib', 'parent_permlink': 'poll-many-in-us-support-trump-decision-to-kill-iran-general', 'author': 'steemcleaner', 'permlink': 'steemcleaner-re-munaibpoll-many-in-us-support-trump-decision-to-kill-iran-general', 'title': '', 'body': 'Warning! This user is on our black list, likely as a known plagiarist, spammer or ID thief. Please be cautious with this post!\nIf you believe this is an error, please chat with us in the #appeals channel in [our discord](https://discord.gg/7FkETjJ).', 'json_metadata': '', '_id': '69548f80e7dffd82fc37a861e42169057df0957e', 'timestamp': datetime.datetime(2020, 1, 25, 3, 46, 15, tzinfo=<UTC>), 'block_num': 40226710, 'trx_num': 40, 'trx_id': '33e920525f1bfd984b961b645d9aab7e7748f059'}
English Edition:
installs beem by Anaconda and develops a python robot of steem
!shop