create account

steem-python tips #4 - See who resteems your posts by emrebeyler

View this thread on: hive.blogpeakd.comecency.com
· @emrebeyler ·
$30.44
steem-python tips #4 - See who resteems your posts
<img src="https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drxhdemuq4r4ezSCFC6xhAknvQspB_1680x8400">

#### Resteem
***

Resteem is defined inside a "custom_json" operation. It doesn't have a separated operation type. It's basically counterpart of *"retweet"*, the concept you may be familiar with Twitter.

Condenser interface (Steemit) or other interfaces doesn't show that information that who resteemed your posts. Let's find out who supports our posts by resteeming.

#### Main Flow of the script

- Go through the account history
- Filter main post creations
- Check resteemers and add them to a counter
- Get an output with cool visualization

Since going through the history takes a lot of time, I have only analyzed my account's last 30 days. If you care to wait, you can just remove that check and get all history.


#### Script
***

```
from steem import Steem
from steem.account import Account
from steem.post import Post
from collections import Counter
import steembase
import pygal
def resteemers(steemd, username, output_path):
    processed_posts = set()
    resteemer_list = list()
    resteemed_posts = list()
    acc = Account(username, steemd_instance=steemd)
    for comment in acc.history_reverse(filter_by=["comment"]):
        # don't process updates
        post_identifier = "@%s/%s" % (
            comment.get("author"), comment.get("permlink"))
        if post_identifier in processed_posts:
            continue
        processed_posts.add(post_identifier)
        # don't process resteems of the author
        if comment.get("author") != username:
            continue
        try:
            post = Post(comment, steemd_instance=steemd)
        except steembase.exceptions.PostDoesNotExist:
            continue
        if post.time_elapsed().total_seconds() > 2592000:  # 1 month
            break
        # don't process comments
        if not post.is_main_post():
            continue
        resteemers = steemd.get_reblogged_by(
            post.get("author"), post.get("permlink"))
        resteemers.remove(username)
        if len(resteemers) == 0:
            continue
        for resteemer in resteemers:
            resteemer_list.append(resteemer)
            resteemed_posts.append(post.identifier)
    most_resteemed_posts = Counter(resteemed_posts).most_common(5)
    most_resteemers = Counter(resteemer_list).most_common(5)
    line_chart = pygal.Bar()
    line_chart.title = 'Most Resteemed Posts (%s)' % username
    for item in most_resteemed_posts:
        line_chart.add(item[0], item[1])
    line_chart.render_to_file("%s/most_resteemed.svg" % output_path)
    pie = pygal.Pie()
    pie.title = 'Resteemers of %s' % username
    for item in most_resteemers:
        pie.add(item[0], item[1])
    pie.render_to_file("%s/resteemers.svg" % output_path)
def main():
    s = Steem(nodes=["https://api.steemit.com"])
    resteemers(s, "emrebeyler", "/tmp/")
if __name__ == '__main__':
    main()
```

See the script nicely formatted at [Github Gists](https://gist.github.com/emre/c2f3a0552866a2f877fa0a6588bd5ac0).

#### Example Outputs
***

**1. Most resteemed posts**
![Screen Shot 2018-03-06 at 10.11.12.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1520320367/frbxiyuiaxwhoclsry3z.png)

**2. Usual resteemers**
![Screen Shot 2018-03-06 at 10.10.35.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1520320393/kxvw21sqq9klgsmebtp8.png)

#### Requirements
***

You need to have **steem-python** and **pygal** libraries installed in your local python environment.

Have fun.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 47 others
properties (23)
authoremrebeyler
permlinksteem-python-tips-4-see-who-resteems-your-posts
categorysteemdev
json_metadata{"community":"busy","app":"busy/2.4.0","format":"markdown","image":["https://steemitimages.com/0x0/https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/U5drxhdemuq4r4ezSCFC6xhAknvQspB_1680x8400","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1520320367/frbxiyuiaxwhoclsry3z.png","https://steemitimages.com/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1520320393/kxvw21sqq9klgsmebtp8.png"],"links":["https://gist.github.com/emre/c2f3a0552866a2f877fa0a6588bd5ac0"],"tags":["steemdev","python","programming","sndbox","busy"]}
created2018-03-06 07:15:42
last_update2018-03-06 07:15:42
depth0
children10
last_payout2018-03-13 07:15:42
cashout_time1969-12-31 23:59:59
total_payout_value27.442 HBD
curator_payout_value3.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,559
author_reputation448,535,049,068,622
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,562,131
net_rshares7,479,881,223,316
author_curate_reward""
vote details (111)
@aniket26 ·
Thank you so much dude. It gave me lot of information. You are doing a great work. These accurate stats. Your blog is worthy. Keep it up
properties (22)
authoraniket26
permlinkre-emrebeyler-201836t13220565z
categorysteemdev
json_metadata{"tags":["steemdev","python","programming","sndbox","busy"],"app":"esteem/1.5.1","format":"markdown+html","community":"esteem"}
created2018-03-06 07:32:21
last_update2018-03-06 07:32:21
depth1
children0
last_payout2018-03-13 07:32:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length136
author_reputation101,188,846,626
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries
0.
accountesteemapp
weight1,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,564,702
net_rshares0
@artizm ·
hey.  bu çok faydalı bir paylaşım. sevdim
properties (22)
authorartizm
permlinkre-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180309t204418347z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-09 20:44:18
last_update2018-03-09 20:44:18
depth1
children0
last_payout2018-03-16 20:44:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation28,441,917,321,225
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id43,395,219
net_rshares0
@siklosi ·
$0.06
Just tried it now. Works great. Thanks!!!
https://s9.postimg.org/sb0ji5hen/image.jpg
👍  
properties (23)
authorsiklosi
permlinkre-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180306t095038923z
categorysteemdev
json_metadata{"tags":["steemdev"],"image":["https://s9.postimg.org/sb0ji5hen/image.jpg"],"app":"steemit/0.1"}
created2018-03-06 09:50:39
last_update2018-03-06 09:50:39
depth1
children1
last_payout2018-03-13 09:50:39
cashout_time1969-12-31 23:59:59
total_payout_value0.064 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length84
author_reputation1,174,722,426,112
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,587,485
net_rshares16,437,528,706
author_curate_reward""
vote details (1)
@emrebeyler ·
looks cool :)
👍  
properties (23)
authoremrebeyler
permlinkre-siklosi-re-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180306t095309344z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-06 09:53:09
last_update2018-03-06 09:53:09
depth2
children0
last_payout2018-03-13 09:53:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length13
author_reputation448,535,049,068,622
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,587,906
net_rshares523,789,615
author_curate_reward""
vote details (1)
@sindore ·
$0.03
Ugh, another new concept to me. What does it mean to resteem? To post another person's content as your own - or with their names on it?

And is it a good thing when your content is resteemed?
👍  
properties (23)
authorsindore
permlinkre-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180306t074503586z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-06 07:46:03
last_update2018-03-06 07:46:03
depth1
children2
last_payout2018-03-13 07:46:03
cashout_time1969-12-31 23:59:59
total_payout_value0.024 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length191
author_reputation97,983,227,980
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,566,862
net_rshares8,218,764,353
author_curate_reward""
vote details (1)
@emrebeyler ·
> To post another person's content as your own - or with their names on it?

Yes. 

> And is it a good thing when your content is resteemed?

Also, yes. Your content will gain more visibility since it will be also featured on the resteemer's feed.
properties (22)
authoremrebeyler
permlinkre-sindore-re-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180306t074844260z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-06 07:48:45
last_update2018-03-06 07:48:45
depth2
children1
last_payout2018-03-13 07:48:45
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length247
author_reputation448,535,049,068,622
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,567,321
net_rshares0
@sindore ·
I see. Thank you for clearing this up for me :)
properties (22)
authorsindore
permlinkre-emrebeyler-re-sindore-re-emrebeyler-steem-python-tips-4-see-who-resteems-your-posts-20180306t094216257z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-06 09:43:15
last_update2018-03-06 09:43:15
depth3
children0
last_payout2018-03-13 09:43:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length47
author_reputation97,983,227,980
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,586,251
net_rshares0
@xeniaioannou ·
$0.03
So what is the benefit of reposting to the person who reposts?
👍  
properties (23)
authorxeniaioannou
permlinkre-emrebeyler-201836t183641161z
categorysteemdev
json_metadata{"tags":["steemdev","python","programming","sndbox","busy"],"app":"esteem/1.5.1","format":"markdown+html","community":"esteem"}
created2018-03-06 08:06:45
last_update2018-03-06 08:06:45
depth1
children2
last_payout2018-03-13 08:06:45
cashout_time1969-12-31 23:59:59
total_payout_value0.021 HBD
curator_payout_value0.007 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length62
author_reputation336,859,675,984
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries
0.
accountesteemapp
weight1,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,570,309
net_rshares8,218,764,353
author_curate_reward""
vote details (1)
@emrebeyler ·
For the reposter, there is no benefit. You repost and the content reaches a wider audience.
👍  
properties (23)
authoremrebeyler
permlinkre-xeniaioannou-re-emrebeyler-201836t183641161z-20180306t080902389z
categorysteemdev
json_metadata{"tags":["steemdev"],"app":"steemit/0.1"}
created2018-03-06 08:09:03
last_update2018-03-06 08:09:03
depth2
children1
last_payout2018-03-13 08:09:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length91
author_reputation448,535,049,068,622
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,570,664
net_rshares505,302,923
author_curate_reward""
vote details (1)
@xeniaioannou ·
Thanks
properties (22)
authorxeniaioannou
permlinkre-emrebeyler-201836t194358200z
categorysteemdev
json_metadata{"tags":"steemdev","app":"esteem/1.5.1","format":"markdown+html","community":"esteem"}
created2018-03-06 09:14:03
last_update2018-03-06 09:14:03
depth3
children0
last_payout2018-03-13 09:14:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6
author_reputation336,859,675,984
root_title"steem-python tips #4 - See who resteems your posts"
beneficiaries
0.
accountesteemapp
weight1,000
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id42,581,550
net_rshares0