How to Set up Automatic Random Posts With Python, Schedule, & Beempy!


Screen Shot 2019-08-31 at 3.36.26 PM.png

I simply used the Python Schedule API to run my Beempy random image script on a timer!

I just set @honusurf to post a random image post once every 10 minutes, I am writing this post while I wait with my fingers crossed, and it worked. Don't worry, I won't leave it on forever, just shifts. I will set the timer to every 6 hours possibly?? What do you think?? I don't want repeats, at least too many so I still need to feed the machine with my original pics, housekeeping/ bot maintenance is still a lotta work!

Heree's the script:


!/usr/local/bin/python3

from beem.imageuploader import ImageUploader
from beem import Steem
import random, os
import schedule
import time

def job():
if name == "main":
stm = Steem()
author = "honusurf"
path = "/Users/nick/random-surf"
random_filename = random.choice([
x for x in os.listdir(path)
if os.path.isfile(os.path.join(path, x))
])
image_path = random_filename
image_uploader = ImageUploader(steem_instance=stm)
img_link = image_uploader.upload(image_path, author, image_name="@honusurf:)")

    title = "Random SURF by @honusurf!!"

    body = "Original Maui Surf Pics by @honusurf. "\
           "Random photo uploaded with beempy image:![x]("\
           "%s" % img_link["url"]
    parse_body = True
    self_vote = False
    tags = ["honu", "photo", "original", "maui", "beem", "bot", "post"]
    stm.post(title, body, author=author, tags=tags, parse_body=parse_body, self_vote=self_vote)

schedule.every(10).minutes.do(job)
while True:
schedule.run_pending()
time.sleep(1)

This little script is helpful, I just launched it and @honusurf already did one post on it's own! = Success! = Makes my life easier!

There's still a lot I need to do to make the script better. I.E. delete image after posting so I don't get repeats!! The image folder is just used organize the groups, and the beempy still reads the images from the home directory, so that could be tweaked a bit. I also need to throw the hyperlink in to the large image! Also optimizing my image, getting AI to comment on the image and describe it, lol! Tons of work too do! If anyone has any suggestions and or additions please post in the comments below!

Screen Shot 2019-08-31 at 3.51.18 PM.png
Screen Shot 2019-08-31 at 3.53.19 PM.png

Screen Shot 2019-08-31 at 4.12.16 PM.png

Then I had to shut it down!All tests worked out well, now for adding some more images and getting this set up for my other accounts!! Wow I really like thi Python stuff a lot!Screen Shot 2019-08-31 at 4.24.41 PM.png

Screen Shot 2019-08-31 at 4.24.24 PM.png

Followw @coininstant for more!


Comments 7


How I wish I could do coding!
My brain is too slow!
Perhaps I should go to some classes.

You are a genius to be able to code like that!
Have a nice weekend!

01.09.2019 04:28
0

Hmmm ...HEy I just say it .. you user name comments I not see here in steemit , but when I use esteem surfer then this takes them open and lets me see it what you text .

01.09.2019 05:08
2

Oh yeah that is because I got my comments stricken from the posts! To see my conversations you have to know where to find them.

01.09.2019 05:53
7

OK ..ok :)
And how is day there? ... I hope sun is up and strong . :)

01.09.2019 06:02
1

Actually it is just night time right now out here, sun just set about an hour ago, it was so rainy & clouded in I could not get a pic.

01.09.2019 06:23
7

Here soon winter back and also lot times very rainy ... this how here summer ends :)

01.09.2019 06:47
1

I really need to look into Python

Posted using Partiko Android

03.09.2019 05:30
1