Hi Steemians, let's build BOTS!
On this blog I want to document my progress in implementing bots for the STEEM blockchain.
In my last post I tried to install steem-python on Ubuntu 16.04, but I failed.
Upgrade to Ubuntu 17.10
Instead I tried to upgrade to 17.04, but this was also not possible because an python library was missed. I contacted the privex supported and asked them to install a clean 17.04. instead. After some hours my new server was ready. Awesome job, @privex!
Since @felixxx's installation guide is based on Ubuntu 17.10, and my system was running 17.04, I first upgraded to 17.10. Just type
do-release-upgrade
and answer every question with yes or select the default option.
Installation ala @felixxx
I installed steem-python according to @felixxx's guide, but only needed to change the order of the commands. The scrypt installation requires some aes headers, so install libssl-dev infront of scrypt.
sudo apt install python3-pip
sudo apt-get install libssl-dev
pip3 install setuptools
pip3 install scrypt
pip3 install wheel
pip3 install pytest
pip3 install steem
The first script from felixxx
I'm a lazy coder and just copy pasted @felixxx's first script and started it ...
from steem.blockchain import Blockchain
from steem.post import Post
b = Blockchain()
s = map(Post, b.stream(filter_by=['comment']))
for post in s:
if post.is_main_post():
print('https://steemit.com/tag/@' + post['author'] + '/' + post['permlink'])
and it failed.
$ python3 firstscrypt.py
WARNING:urllib3.connectionpool:Retrying (Retry(total=19, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff6689c1208>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /
WARNING:urllib3.connectionpool:Retrying (Retry(total=18, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff6689c12e8>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /
WARNING:urllib3.connectionpool:Retrying (Retry(total=17, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff6689c1358>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /
WARNING:urllib3.connectionpool:Retrying (Retry(total=16, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff6689c1470>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /
Set a steemd node
It failed because steemit.com disabled their legacy steemd node around 2 weeks ago.
It's very easy to set an alternative steemd node in steem-python. I usually use these code fragments, but I'm not sure if this is the most efficient and secure option.
from steem.blockchain import Blockchain
from steem.post import Post
from steem.instance import set_shared_steemd_instance
from steem.steemd import Steemd
from steem.steem import Steem
# steemd_nodes = ['https://api.steemit.com']
steemd_nodes = ['https://steemd.pevo.science']
set_shared_steemd_instance(Steemd(nodes=steemd_nodes))
steem = Steem()
b = Blockchain()
s = map(Post, b.stream(filter_by=['comment']))
for post in s:
if post.is_main_post():
print('https://steemit.com/tag/@' + post['author'] + '/' + post['permlink'])
I first tried the new node from steemit.inc (https://api.steemit.com), but I got no results. Later I switched to @pharesim's public node (https://steemd.pevo.science), and the script worked.
$ python3 firstscript.py
https://steemit.com/tag/@rslabbert/death-of-my-dishwasher
https://steemit.com/tag/@rahmats/the-beauty-of-heaven-in-the-afternoon-when-the-sun-begins-to-disappear-13fec1c539d8c
https://steemit.com/tag/@lawyergt/qxbus
https://steemit.com/tag/@lgh950927/k-pop
https://steemit.com/tag/@cityslicker/wanna-have-some--2018-01-15-11-27-45
https://steemit.com/tag/@rnb/does-coffee-kill-your-heart-and-bacon-is-more-harmful-than-cigarettes
Next steps
In my next tutorial I plan to start interactions between steem-python and discord. Stay tuned.
Looking forward to the continued parts of this project. Who would've ever thought I'd actually WANT to learn a new language after being out of the game for 15yrs. Thanks for this!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit