Import Medium Following RSS Feeds into Feedly via Python

Mike Reynolds
3 min readJun 25, 2024

--

I am a long-time fan and user of RSS feeds. Back in the days of Google Reader and the debut of Feedly, RSS feeds were a great way to read the internet. However, since then, I haven’t found them all that useful since I’m less often scouring the web for information. But due to Generative AI and finally springing for a Medium subscription (which is well worth it), I now have the desire to add many Medium RSS feeds to Feedly. But how?

Ideally, I’d want to have a single RSS feed of everyone I’m following that I can easily pull into Feedly without needing to use a password. I find password-protected RSS feeds to be a nuisance. Thus, how to import many author feeds into my Feedly? Enter Python and ChatGPT’s coding prowess.

Step-by-Step Guide to Create RSS Feeds from Medium Following List

1) Visit Your Following List:

  • First, visit the list of people you follow on Medium. Mine is located at: https://medium.com/@reynmike/following.
  • To get there, click on your profile pic, go to your profile, then under “Following” click “See all”.

2) Save the HTML Page:

  • Save this HTML page to your folder (e.g., C:\Users\yourname\yourfolder\Medium).
  • Once it’s done saving, which might take some time due to downloading all the avatar pics, rename the file to following.html.
  • It’s then okay to delete the folder with all the additional downloaded content you won’t need.

3) Leverage this Python script:

  • Below is the Python script I used to extract Medium usernames from the saved HTML, convert them to feed URLs, and manage them.
import os
import re

# Define the directory and file paths
directory = r"C:\Users\yourname\yourfolder\Medium"
followers_txt = os.path.join(directory, "followers.txt")
followers_prior_txt = os.path.join(directory, "followers_prior.txt")
followers_new_txt = os.path.join(directory, "followers_new.txt")
followers_new_opml = os.path.join(directory, "followers_new.opml")
following_html = os.path.join(directory, "following.html")

# Step 1: Extract unique username mentions from following.html
if os.path.exists(following_html):
with open(following_html, 'r', encoding='utf-8') as f:
html_content = f.read()

# Extract usernames using regex
usernames = set(re.findall(r'https://medium\.com/@(\w+)', html_content))

# Convert to feed URLs
feed_urls = sorted(f"https://medium.com/feed/@{username}" for username in usernames)

# Write the sorted unique feed URLs to followers.txt
with open(followers_txt, 'w') as f:
for url in feed_urls:
f.write(url + '\n')

# Step 2: Compare followers.txt with followers_prior.txt and write new usernames to followers_new.txt
if os.path.exists(followers_txt) and os.path.exists(followers_prior_txt):
with open(followers_txt, 'r') as f:
current_followers = set(f.read().splitlines())

with open(followers_prior_txt, 'r') as f:
prior_followers = set(f.read().splitlines())

new_followers = current_followers - prior_followers

# Write new followers to followers_new.txt
with open(followers_new_txt, 'w') as f:
for url in sorted(new_followers):
f.write(url + '\n')

# Step 3: Copy followers.txt to followers_prior.txt to prepare for the next time
if os.path.exists(followers_txt):
with open(followers_txt, 'r') as f:
followers_content = f.read()
with open(followers_prior_txt, 'w') as f:
f.write(followers_content)

# Step 4: Transform followers_new.txt into an OPML file
if os.path.exists(followers_new_txt):
with open(followers_new_txt, 'r') as f:
new_followers = f.read().splitlines()

opml_header = """<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>New Followers</title>
</head>
<body>
<outline text="New Followers">
"""
opml_footer = """
</outline>
</body>
</opml>
"""
opml_body = ""
for url in new_followers:
opml_body += f' <outline type="rss" text="{url}" xmlUrl="{url}"/>\n'

with open(followers_new_opml, 'w', encoding='utf-8') as f:
f.write(opml_header + opml_body + opml_footer)

print("Script execution completed.")

4) Load the OPML File into Feedly:

  • To load the OPML file into Feedly, follow these steps:
  1. Log in to your Feedly account.
  2. Click on your profile icon and select “Organize”.
  3. Click “Import OPML” and upload the followers_new.opml file.
  4. Your new Medium RSS feeds should now be added to Feedly.

Happy reading!

--

--

Mike Reynolds

Ex-Disney strategist, construction strategy, mathematician, 10X marathoner, CrossFit/HIIT, nutritionist, Keto. MS Math/Stat, MBA, CSCP. Likes squirrels & cats.