How to Monetize Your Old PostssteemCreated with Sketch.

in #steemit7 years ago (edited)

How to Monetize Your Old Posts

I am an artist (who is also a programmer) so I have lots of images on my Steemit posts. Being new here my first posts did not get as much attention as my newer blog posts. Now I really want people to see my old posts and vote on my new posts.

This is the first solution I came up with. Collect all the images from old posts and put them in a new gallery post. It would take me a very long time open each post and copy the image link out of it. It only supports that last 100 posts you have made. I will try to figure out a way to go back further in time.

So I made a script to do it for me. It will be at the bottom of this post.

Look at my gallery page to see what it looks like.

bardionson's gallery

It will filter out any resteems you have done and any images from @steemitboard.

But you have to install Python and some Python packages to get it to work. I am still using Python 2.7

Install Python on a Macintosh

Macintosh
Install Brew with the directions at https://brew.sh/
brew install python or sudo easy_install pip

Install Python on Windows:

https://github.com/BurntSushi/nfldb/wiki/Python-&-pip-Windows-installation
https://matthewhorne.me/how-to-install-python-and-pip-on-windows-10/

Install Python on Linux

https://www.tecmint.com/install-pip-in-linux/

sudo apt-get install python2
sudo apt-get install python-pip python-dev build-essential 
sudo pip install --upgrade pip 
sudo pip install --upgrade virtualenv 

Specific Packages Needed for the Script

sudo pip install BeautifulSoup4
sudo pip install selenium
sudo pip install requests

Chrome and Chromedriver Install

I am using Selenium to read the list of posts from a page I created at http://wowak.com/blog.html?user=bardionson. This page will show a list of your blog posts if you put your username after user= .

The script uses Chrome in way that you will not see the browser startup. (headless) So you need to install Chrome and the Chromedriver.

On Macintosh use this commands

brew install chromedriver
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

On Windows see these directions and down load the software.

The Output

The "Make Photo Post" script will output a list of html links. The links will point at the original post the image came from. Inside the link is the html image tag that will display the image on the page. Copy the list of html links called "<a href" from the output and paste into the Steemit blog post editor. You need to add your own title and heading and any text you want.

The Script

I have placed the most up to date script at my github repository. https://github.com/bardionson/steemit-tools If I need to make a change to the code it will show up there. Shown below is a static version of that code.

The command to run this code is

python make_photo_gallery.py [your username] > [the file you want the links in]
python make_photo_gallery.py bardionson > my_photo_gallery_post.html

Python Code:

note: Steemit made me put a period after img tag in the code below. I was getting an image upload error remove the periods before using.

import collections
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
import time
import sys
reload(sys)
sys.setdefaultencoding('utf8')

options = webdriver.ChromeOptions()
options.add_argument('headless')
username = sys.argv[1]
root_url = "http://wowak.com/blog.html?user="+username
page = requests.get(root_url, verify=True).content
url = "https://steemit.com"
browser = webdriver.Chrome(chrome_options=options) #replace with .Firefox(), or with the browser of your choice
# browser = webdriver.Firefox()
browser.get(root_url)
time.sleep(5)
links = browser.find_elements_by_xpath("//*[@href]")
data_links = collections.OrderedDict()
for link in links:
   #print link.get_attribute("href")
   a = link.get_attribute("href")
   # filter out the resteems
   if (username in a):
      key = a.decode('utf-8') 
      data_links[key] = a.decode('utf-8') 

data_images = collections.OrderedDict()
for keys,values in data_links.items():
   page = requests.get(values, verify=True).content
   soup = BeautifulSoup(page, "html.parser")
   images = soup.find_all('img')
   counter = 0
   for image in images:
      # filter out steemitboard
      try:
         if ('steemitboard' not in image.attrs['src']):
            try:
               # on these next lines Steemit made me put a period after img. 
               # I was getting an image upload error
               # remove the period before using
               key = "<img. src='"+image.attrs['src']+"' alt='"+image.attrs['alt']+"'>"
            except KeyError:
           key = "<img. src='"+image.attrs['src']+"' alt='"+values+"'>"
            data_images[key] = values
      except KeyError:
    print ''

for keys,values in data_images.items():
   print "<div class='pull-left'><a href='"+values+"'>"
   print keys.decode('utf-8') 
   print "</a></div>"

browser.quit()

print "Created by <a href='https://steemit.com/@bardionson>@BardIonson'</a><br>"
print "Get Directions at <a href='https://steemit.com/@bardionson/how-to-monitize-your-old-posts'>Make Photo Gallery'</a>"

If you like this please vote and resteem. Comment with any suggestions or questions please.

I am looking into someway to host this on a web application so you would not have to install python. My current web provider does not support Python or Selenium. Follow me for updates on my progress.

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by bard ionson from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.