在前一篇帖子中
- Python程序中使用集合计算简化问题处理
我们聊到如何使用集合的差集功能筛查出用户组A中不属于用户组B的元素
并举了一个栗子:
找出用户组A中没有给帖子@oflyhigh/xxxx 投票的用户
你可能很惊讶,莫非O哥用技术手段排查不给他投票的用户,然后拉黑吗?
比如说台湾第一美女 @deanliu 老师就吓哭了
其实O哥没那么小气的啦
不过还真是用来查谁没投票的,至于用途嘛,暂且保密
然后恰逢 @jubi 小兄弟问到:
代码是看懂了,就是不知道这个list_user怎么得到 哈哈,我用上了我所有了编程知识了。:)
PS 我可是点赞了哟
就一并多说点。
获取帖子投票列表
获取帖子投票列表,我知道的至少有四种方法:
- 使用SteemData
- 使用官方Python库中的Post类
- 使用API get_content
- 使用API get_active_votes
当然其实还有JS, PHP, Ruby等各种库各种类,你可以选择你擅长的,我不懂的就不多说啦。
1. 使用SteemData
有关如何使用 SteemData
可以参考我以前的一些文章
使用SteemData 你可以有好多种方式来查询出投票列表
比如说从Posts中查询, 或者从Operations中查询,或者从AccountOperations中查询
比如我从Posts中查询Steemit上第一篇文章: Welcome to Steem!
部分投票如下:
是不是很好玩?
不过SteemData目前有个问题,就是数据延迟,说白了,不新鲜,这就尴尬了
人家给你投过了,你查出来没投,岂不是冤枉人了?
我在Github上反馈过这个问题,作者的答复是自建节点,值得期待啊
2. 使用官方Python库中的Post类
Post类其实是对API get_content的封装
用起来就不用太关心下边的东西啦
post = Post('@author/permlink')
这样就取到帖子啦
然后
post['active_votes']
就是帖子的投票信息啦
以我之前一个测试的帖子为例, post['active_votes']
部分如下:
'active_votes': [{'percent': 5000,
'reputation': '129952225494384',
'rshares': '736202067284',
'time': '2017-07-23T08:43:33',
'voter': 'oflyhigh',
'weight': 875336},
{'percent': 5000,
'reputation': 0,
'rshares': 407577814,
'time': '2017-07-23T08:43:33',
'voter': 'eval',
'weight': 194}],
3. 使用API get_content
之前我们说过,Post类其实是对API get_content的封装,所以两者其实是类似的
Post类经过封装更易使用
而get_content更直截了当
API定义如下:
discussion get_content( string author, string permlink )const;
4. 使用API get_active_votes
你可能会问既然,有了1, 2,3 种方法,为何还要第四种呢?是不是没啥写的在凑字数?😡
呃,不是这样的
如果你使用过第二、第三种方法,就会发现它们返回好多信息,比如文章内容、作者信用、奖励信息等等。这些信息在做复杂的判断时非常有用,但是如果就是为了找到投票信息,读回来一火车的数据,岂不是浪费?
浪费是可耻的行为,既增加系统负载又费电,所以我们要杜绝浪费。
所以 get_active_votes 就勇敢的站了出来。
这个API 很好理解,就是拿出对应帖子的投票信息。
API 定义如下:
vector<vote_state> get_active_votes( string author, string permlink )const;
代码示例
超简单的哦
from steem import Steem
steem = Steem()
active_votes = steem.get_active_votes('oflyhigh', '4j3232-python')
list_voter = [vote['voter'] for vote in active_votes]
print(list_voter)
list_user = ['oflyhigh', 'laodr', 'deanliu', 'ace108', 'rivalhw', 'lemoojiang']
list_x = list(set(list_user) - set(list_voter))
print(list_x)
咳咳咳,后边三段代码是我不小心加上去的。我胸怀宽广,不会记仇的😕
看起来挺有趣的,但要使用Python这么复杂的东西就超出了我的能力范围, 呵呵!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😄 写出像 @rea 妹妹那样的精彩文章,也超出我的能力范围 😢
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Very interesting post , thanks :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
我还特地看了一下美女,可惜头像好模糊
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
我一直以为 @deanliu 刘系主任是个男的呢,原来是美女呢。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
對,他是有名的劉美女!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
👌
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
我一直以为oflyhigh在开玩笑。难道真是美女?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
美若天仙啊~
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
your post looks interesting
i wish there was an english translation
anyway thanks for sharing
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
All I can see from that text is "buy Antshares." China is about to go crazy with crypto, and I'm happy for them.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Folback Vote :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
邏輯上大概是明白了,但對於只學過C++的我來說覺得太難了T^T
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
呃,C++ 好难的
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
我一直以为 @deanliu 刘系主任是个男的呢,原来是美女呢。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
咦,你咋能用我的ID发帖呢?你是谁?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
來看看沒投票的被拉去...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😄
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
好奇你的list_user有哪些人 哈哈哈。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
嘘,保密
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
不是很懂,学习了
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
一起学习
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
有意思!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
谢谢夸奖
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
唔吼鐘意你們啊!^_^
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
不如一搶打死我吧!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
為麼這樣說我.... 我訴台灣第一美女捏
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
美女饒命呀!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😄刘老师曝照啦 👏
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
這張狀況不好,你看大家都嫌隙我.... >_<
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
可以舉報嗎,是nfsw的類別啊...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
上報紙嗎?我常常上報紙啊!謝謝你的熱心.... 是National Famous Sweetie Weekly嗎?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
這。。比死更難受。。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
哼!你這臭男人.... 我只想等你家小帥哥長大...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
!!!!!不要啊!!!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
姊,不俗蘇胡啊~~
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
your post always too good :)
can you seen my dead body and aunt drawing post its realy good you naver seen before
if you like then folllooo me and voootee uuppp.,.,...
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I am impressed with you .. thanks information.semoga we can be friends well .. follow me @riansteem
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
O哥这技术派,是牛得真不得了啊。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😄 这真没啥技术含量的
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
这真是会者不难,难者不会。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Folback Vote :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
o哥,你只喜歡跟台灣的美女聊天!
那香港呢? 😝
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
😄 咋觉得我要变色狼呢 😢
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
你剛剛已經變了😝(開玩笑,別打我~)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
也许是因为刘美女太漂亮啦
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
你也這麼覺得吧?被baby這麼稱讚... 頓時覺得
好害羞天啊!我該去吃藥了....
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
我刚才点赞的时候点不出,系统显示:Cannot increase payout within last twelve hours before payout.
这又是出什么bug了?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
不是BUG
6天半到7天之间的帖子不能点赞
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
哦,原来快付钱时不让点赞
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Here you'll find only officially released television promos and teasers, along with exclusive interviews and more. Make sure to follow to never miss a video!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
这个有没有 java的api接口
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
其实就是HTTP通信
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
不错,我也能玩了
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
还没搞Python但这里的资料可做参考玩steemsql. 谢谢。
可能搞定后不会错过。
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
哇咔咔,我就是举个栗子
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
举多几个.:-)
Source: Pixabay.com
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit