[Steem Developer Portal] PY: Get Voters List On Post | TutorialsでPYTHONを学ぶ

in SteemCoinPan •  last month  (Edited)

こんにちは、@yasuです。

Steem Developer Portal
今回は、PY: Get Voters List On Postを学びたいと思います。
https://developers.steem.io/tutorials-python/get_post_details

実行環境はこちらです。
https://repl.it/

コード(修正前)

投稿を5個表示します。
選択した投稿に対して、以下に示すVoting情報を表示します。
percent
reputation
rshares
time
voter
weight

#1. App setup
import pprint
from pick import pick
# initialize Steem class
from steem import Steem

s = Steem()


#2. Post list
query = {
    "limit":5, #number of posts
    "tag":"" #tag of posts
    }
#post list for selected query
posts = s.get_discussions_by_active(query)

title = 'Please choose post: '
options = []
#posts list options
for post in posts:
    options.append(post["author"]+'/'+post["permlink"])
# get index and selected filter name
option, index = pick(options, title)


#3. Voters list
voters = s.get_active_votes(posts[index]["author"],posts[index]["permlink"])


#4. Print output
# print voters list for selected post
pprint.pprint(voters)
pprint.pprint("Selected: "+option)

もともとのコードではエラーが発生しました。

image.png

コード(修正後)

原因は不明ですが、
get_discussions_by_active()メソッドを
get_discussions_by_created()メソッドに変更しました。

#1. App setup
import pprint
from pick import pick
# initialize Steem class
from steem import Steem

s = Steem()


#2. Post list
query = {
    "limit":5, #number of posts
    #"tag":"" #tag of posts
    "tag":"jp" #tag of posts  #REP
    }
#post list for selected query
#posts = s.get_discussions_by_active(query)
posts = s.get_discussions_by_created(query) #REP


title = 'Please choose post: '
options = []
#posts list options
for post in posts:
    options.append(post["author"]+'/'+post["permlink"])
# get index and selected filter name
option, index = pick(options, title)


#3. Voters list
voters = s.get_active_votes(posts[index]["author"],posts[index]["permlink"])


#4. Print output
# print voters list for selected post
pprint.pprint(voters)
pprint.pprint("Selected: "+option)

実行結果

image.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@yasu transfered 0.5 KRWP to @krwp.burn. voting percent : 3.91%, voting power : 78.56%, steem power : 1912381.55, STU KRW : 1200.
@yasu staking status : 250 KRWP
@yasu limit for KRWP voting service : 0.5 KRWP (rate : 0.002)
What you sent : 0.5 KRWP [46878306 - c0a4d8decdd7092d758b0ca8ea2517603796874a]