Find the Topics Your Medium Story was Curated into Automagically

René
2 min readDec 16, 2020

--

With a little help of an easy to use Python script…

Photo by 🇸🇮 Janko Ferlič on Unsplash

The topics your Medium story was curated into are easy to find when you know where to look. Zulie Rane wrote an excellent story¹ explaining the steps to find these topics manually. In this story I describe how automate these steps.

Prerequisite

We will use the programming language Python to make a little script to automagically return the topics your story was curated into. So make sure you have Python installed on your laptop. If it isn’t preinstalled you can download and install it from python.org.

Script

The script to automate the process of finding the topics for your story is just a few lines of code. I tried to keep things as easy and terse as possible.

import requests, sysdef main(url):
topics = requests.get(url).text.split('Topic:')
if len(topics) > 1:
print([topic.split('"')[0] for topic in topics[1:]])
else:
print('-') # no topics found
if __name__ == "__main__":
main(sys.argv[1])

Save this script to a plain text file and use .py as file extension. I chose topics.py as file name for this demo.

Demo

Running the script is pretty straightforward. It only needs the URL of your story as argument. Run the command below from a terminal or command prompt.

python3 topics.py <url>

Replace the text <url> with the URL of your story on Medium and you are good to go. And as you can see, the topics the story as curated into are automagically returned.

Image by Author

For example, my first story² on Medium was curated into the topics Data Science and Programming.

Final Thoughts

It’s pretty easy to modify the script to return other information as well like publication date, publisher and tags. Hope this was helpful. Let me know your thoughts.

Footnotes

[1]: Zulie Rane (November 8, 2020): How to Tell What Topics Your Medium Story Was Curated Into.

[2]: René (December 7, 2020): Getting Started with Data Analysis in Julia.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

René
René

Written by René

Senior Information Manager with a passion for all things data. Official author of Towards Data Science (TDS).

No responses yet

Write a response