create account

Daily Steem-Python Challenge #10, Win 1 Steem! by steempytutorials

View this thread on: hive.blogpeakd.comecency.com
· @steempytutorials ·
$4.83
Daily Steem-Python Challenge #10, Win 1 Steem!
<center>https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png</center>

For each tutorial we release there will be a relevant challenge where the winner receives 1 STEEM! 

### Challenge
Take the code from the tutorial from [here](https://github.com/amosbastian/steempy-tutorials/blob/master/part_11). In the code you learned how to extract image urls from the Post object. However not every Steem platform stores the post metadata as gracefully as Steemit.com does. Below are 3 example posts where image urls are not as straight forward to retrieve from. 

1. Alter the code that is checks which platform was used to submit the post and use another way to retrieve the image url.

```
https://steemit.com/bescouted/@vladkuneberg/red-green-contrast
https://steemit.com/photofeed/@pcusine/hotel-w-barcelona-1516230216
https://steemit.com/colourfulphotography/@klborillo/flowers-for-sale-2018-01-18-00-15-59
```
<br>
That's it! Good luck to everyone participating!

### Deadline
The prize money will be rewarded to the person that solves the problem first. If there is no solution within 7 days after this post has been submitted the prize pool expires.

### Relevant Tutorial

[Part 10: Use Urls To Retrieve Post Data And Construct A Dynamic Post With Steem-Python](https://steemit.com/utopian-io/@steempytutorials/part-10-use-urls-to-retrieve-post-data-and-construct-a-dynamic-post-with-steem-python)

---

If you have questions about the tutorial or the challenge then don't hesitate to comment below or contact us on [Discord](https://discord.gg/rYTV87W)!
👍  , , , , , , , , , , , , , , , ,
properties (23)
authorsteempytutorials
permlinkdaily-steem-python-challenge-10-win-1-steem
categorycontest
json_metadata{"tags":["contest","python","bot","programming"],"image":["https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png"],"links":["https://github.com/amosbastian/steempy-tutorials/blob/master/part_11","https://steemit.com/utopian-io/@steempytutorials/part-10-use-urls-to-retrieve-post-data-and-construct-a-dynamic-post-with-steem-python","https://discord.gg/rYTV87W"],"app":"steemit/0.1","format":"markdown"}
created2018-01-23 12:04:54
last_update2018-01-23 12:04:54
depth0
children7
last_payout2018-01-30 12:04:54
cashout_time1969-12-31 23:59:59
total_payout_value4.786 HBD
curator_payout_value0.047 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,594
author_reputation31,094,047,689,691
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id31,631,964
net_rshares433,353,084,054
author_curate_reward""
vote details (17)
@emrebeyler ·
$0.24
Here is my [solution](https://gist.github.com/emre/38dba6b42c87341e0dc50b0d7b3fde1a).

I guess the best shot is creating different patterns/adapters for every known platform and if it's not a known platform fallback to general image finder pattern.
👍  , , ,
properties (23)
authoremrebeyler
permlinkre-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180123t140116368z
categorycontest
json_metadata{"tags":["contest"],"links":["https://gist.github.com/emre/38dba6b42c87341e0dc50b0d7b3fde1a"],"app":"steemit/0.1"}
created2018-01-23 14:01:15
last_update2018-01-23 14:01:15
depth1
children2
last_payout2018-01-30 14:01:15
cashout_time1969-12-31 23:59:59
total_payout_value0.200 HBD
curator_payout_value0.041 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length248
author_reputation448,535,049,068,622
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id31,655,889
net_rshares22,065,626,820
author_curate_reward""
vote details (4)
@juliank ·
Your code check out fine, will transfer the Steem. Also learned something from you code, thanks ;)
properties (22)
authorjuliank
permlinkre-emrebeyler-re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180126t044932644z
categorycontest
json_metadata{"tags":["contest"],"app":"steemit/0.1"}
created2018-01-26 04:49:33
last_update2018-01-26 04:49:33
depth2
children0
last_payout2018-02-02 04:49:33
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_length98
author_reputation117,823,071,447,502
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,377,476
net_rshares0
@steempytutorials ·
I agree on that. Will be going over the code now.
properties (22)
authorsteempytutorials
permlinkre-emrebeyler-re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180125t121421114z
categorycontest
json_metadata{"tags":["contest"],"app":"steemit/0.1"}
created2018-01-25 12:14:21
last_update2018-01-25 12:14:21
depth2
children0
last_payout2018-02-01 12:14: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_length49
author_reputation31,094,047,689,691
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,186,292
net_rshares0
@maxg ·
$0.43
Look at the Steemd for this comment.

Unfortunately I think this challenge is _much_ harder than it appears if you want to get finniky with it- especially since some markdown parsers don't always work the way you expect them to. How do you tell the difference between say a [link](https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png) that isn't really part of a post,  and an image? You can also escape the ! to make an image appear as a link. Example: \![link](https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png)

Also - can't assume that the image is going to have a [valid extension](https://stackoverflow.com/questions/5110384/can-i-use-images-without-extension-in-img). 
For example, this is a link if I paste it in straight up.
https://steemitimages.com/DQmS9uzwXDM9HWNSM5G5EPhFd9VLi5Miva5MZdTPjcwL6rb/image
Now if I add the `![](stuff)` it gets interpreted as an image.
https://steemitimages.com/DQmS9uzwXDM9HWNSM5G5EPhFd9VLi5Miva5MZdTPjcwL6rb/image.png

I think the only way to come up with a solution that really works for all platforms is to render the page on Steemit and inspect that for valid image tags with something like BeautifulSoup. Anything else will only work 99% of the time ;)
👍  , ,
properties (23)
authormaxg
permlinkre-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180123t220924740z
categorycontest
json_metadata{"tags":["contest"],"image":["https://steemitimages.com/DQmS9uzwXDM9HWNSM5G5EPhFd9VLi5Miva5MZdTPjcwL6rb/image.png"],"links":["https://cdn.discordapp.com/attachments/404587860872921088/405329216280723458/challenge.png","https://stackoverflow.com/questions/5110384/can-i-use-images-without-extension-in-img","https://steemitimages.com/DQmS9uzwXDM9HWNSM5G5EPhFd9VLi5Miva5MZdTPjcwL6rb/image"],"app":"steemit/0.1"}
created2018-01-23 22:09:24
last_update2018-01-23 22:09:24
depth1
children3
last_payout2018-01-30 22:09:24
cashout_time1969-12-31 23:59:59
total_payout_value0.338 HBD
curator_payout_value0.087 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,278
author_reputation5,859,582,764,121
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id31,753,032
net_rshares39,567,608,962
author_curate_reward""
vote details (3)
@juliank ·
Took some time to go over your comment. All of your points are valid and what they truly show is how complicated a decentralised system is. All of the different apps using their own slight variations makes for these annoying exceptions. 

As for "render the page on Steemit and inspect that for valid image tags with something like BeautifulSoup" that sounds interesting. I have no experience with this. 

How I currently deal with the issue is basically verifying each post beforehand and filtering out any 1% by hand ;)
properties (22)
authorjuliank
permlinkre-maxg-re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180126t045723884z
categorycontest
json_metadata{"tags":["contest"],"app":"steemit/0.1"}
created2018-01-26 04:57:24
last_update2018-01-26 04:57:24
depth2
children0
last_payout2018-02-02 04:57:24
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_length521
author_reputation117,823,071,447,502
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,378,798
net_rshares0
@maxg ·
[Steemd link](https://steemd.com/contest/@maxg/re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180123t220924740z)
properties (22)
authormaxg
permlinkre-maxg-re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180123t221146999z
categorycontest
json_metadata{"tags":["contest"],"links":["https://steemd.com/contest/@maxg/re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180123t220924740z"],"app":"steemit/0.1"}
created2018-01-23 22:11:48
last_update2018-01-23 22:11:48
depth2
children0
last_payout2018-01-30 22:11:48
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_length131
author_reputation5,859,582,764,121
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id31,753,486
net_rshares0
@steempytutorials ·
This one is indeed a lot harder that you might initially think. Actually an issue I have to deal with on a daily basis :P Will be going over your code now
properties (22)
authorsteempytutorials
permlinkre-maxg-re-steempytutorials-daily-steem-python-challenge-10-win-1-steem-20180125t121552195z
categorycontest
json_metadata{"tags":["contest"],"app":"steemit/0.1"}
created2018-01-25 12:15:51
last_update2018-01-25 12:15:51
depth2
children0
last_payout2018-02-01 12:15:51
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_length154
author_reputation31,094,047,689,691
root_title"Daily Steem-Python Challenge #10, Win 1 Steem!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id32,186,617
net_rshares0