How to Hack Your Medium Account

October 14, 2019

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

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 elonmusk@gmail.com 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: https://docs.aws.amazon.com/AmazonS3/latest/user-guide/upload-objects.html

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.

Serverless Handbook
Access free book

The dream team

At Serverless Guru, we're a collective of proactive solution finders. We prioritize genuineness, forward-thinking vision, and above all, we commit to diligently serving our members each and every day.

See open positions

Looking for skilled architects & developers?

Join businesses around the globe that trust our services. Let's start your serverless journey. Get in touch today!
Ryan Jones - Founder
Ryan Jones
Founder
Speak to a Guru
arrow
Edu Marcos - CTO
Edu Marcos
Chief Technology Officer
Speak to a Guru
arrow
Mason Toberny
Mason Toberny
Head of Enterprise Accounts
Speak to a Guru
arrow

Join the Community

Gather, share, and learn about AWS and serverless with enthusiasts worldwide in our open and free community.