Serverless Guru
Published in

Serverless Guru

How to Hack Your Medium Account

Write a script to clean the HTML of your article and repost it elsewhere

Photo (…of a water filtration system ?) by Ivan Bandura on Unsplash

As of 2017, Medium no longer offers Custom Domains. They have an API and a few SDKs for publishing to Medium. What if you want to repost your entire Medium content on your personal domain in one batch?

One way is to download your entire content as a .zip file. The API doesn’t seem to let you do such a large export.

After downloading, the parsing can be done in many ways. The way covered here has a Node.js script in AWS Lambda cleaning HTML uploaded to S3.

You could do this transformation locally, but if you want to repeat this parsing process on a schedule, you may want the reliability and automation of cloud services such as AWS Lambda and CloudWatch Events cron rules.

Steps to downloading your content

  1. Click on your profile picture in the top right corner.
  2. Click on Settings.
Profile Pic > Settings

3. Scroll down and click on “Download your information.”

4. Click “Download .zip”

Download .zip page

5. Read the explanation and click “Export.”

Medium’s explanation of downloads:

Download your information

You can request a .zip file containing HTML files of your Medium posts and drafts, info that you have shared on your profile, stories you’ve clapped on, and more.

We’ll email you at with a link to the .zip file when it’s ready. The link will be available for 24 hours after you receive the email. If you wish to use a different email address, you may change it on the settings page.

By initiating the process to receive these files you are representing that you have all necessary rights and permissions to receive the content included in the file.

Upload to S3

The short version:

  1. Create an AWS account.
  2. Unzip your Medium export locally.
  3. Create an S3 bucket, click upload, and drop your articles folder in there.

The long version:

Parse, filter, clean, save

Once an object is in S3, you can manipulate it in all kinds of ways. If you just want to strip out Medium’s CSS so you can use your own website’s CSS, you could just do a few Regex replacements, as we did with an AWS Lambda function and a Serverless template for Serverless Guru website’s blog.

The replace statements in this script are fragile in that they depend on Medium’s HTML style to stay the same, but it gets the job done for now of porting over dozens of articles all at once while maintaining our own CSS.

Careful: If you use that particular script, it overwrites the contents of the bucket you point it to.

You can either run the function manually by clicking Test in the Lambda console or do it programmatically with CloudWatch Events.

Additional Content:

What does Serverless Guru do?

Serverless Guru can help your company migrate to serverless, build serverless applications, and train your team on serverless development. We help train companies on how to leverage IAC, serverless, and cloud-native services. We help migrate existing cloud applications to serverless and help optimize applications to be more cost-effective. We are a Serverless development partner and an AWS Consulting partner.

What did we miss?

When you leave your answer make sure to either comment below or tweet your answer to @serverlessgurux on Twitter.

Yann Stoneman

Full Stack Cloud Developer — Serverless Guru

LinkedIn — @ystoneman

Twitter — @yannstoneman

Thanks for reading 😃

If you would like to learn more about Serverless Guru, please follow us on Medium, Twitter, Instagram, Facebook, or LinkedIn!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store