In my social media strategy, I write LinkedIn / Twitter posts about random archived articles. This drives traffic & value from my older articles.
Getting your articles.
Go to Substack settings.
At the bottom, you’ll find “Exports”
Export your data.
Wait.
Download it when it’s done.
Extract the posts.csv file from the zip.
Creating your code environment.
You’re going to create a free Python cloud coding environment.
Go to Python Anywhere.
Create a Beginner/Free account (you can currently find that option under pricing).
Click on “Files” at the top, and upload your posts.csv file.
Go back to your dashboard.
Create a new file called something like “random-url.py”
Edit the file.
The code.
Paste in this code.
import csv
import random
articles_to_return = 10
domain = "https://www.scarletink.com/p/"
with open('posts.csv') as csv_file:
csv_reader = csv.DictReader(csv_file)
all_urls = []
for row in csv_reader:
if row["is_published"] == "true":
if row["type"] == "newsletter":
theurl = row["post_id"].rsplit(".", 1)[1]
all_urls.append(domain + theurl + '/')
print(f'Found {len(all_urls)} total articles. Returning {articles_to_return} random ones.\n')
numreturned = 0
while (numreturned < articles_to_return):
randomarticlenum = int(random.random() * len(all_urls))
thisarticleurl = all_urls[randomarticlenum]
all_urls.remove(thisarticleurl)
print(f'{thisarticleurl}')
numreturned += 1
Edit the “domain” to change it to your domain.
If you want to get a nice long list of URLs, change the “10” of articles_to_return to something bigger. FYI, if that number is greater than your number of articles, it’ll break. Because I didn’t build in any error checking.
Run it.
When you’ve edited your URL, click the blue “Run” button in the upper-right.
If nothing has gone wrong, you’ll get back a list of 10 random URLs for published articles on your site.
Now write social media for those.