There are several reasons why you might want to convert a Medium article from its original format to Markdown and then to HTML. In this article, I'll explain to you how you can do it using Python programming language with a few simple steps.
Some of the benefits of using Markdown include:
Overall, converting a Medium article to Markdown can provide many benefits, such as making it easier to edit and format the article and enabling you to integrate it with other tools and platforms.
Whether or not this is the right approach for you will depend on your specific needs and goals.
Now let's jump to the code!
The code you provided is a Python script that uses the medium_api
library to access the Unofficial Medium API and convert an article from Markdown to HTML.
You can install medium-api
using the following command:
pip install medium-api
Here is a brief explanation of what the code does:
os
and markdown
libraries, which are used to access environmental variables and convert Markdown to HTML, respectively.Medium
class from the medium_api
library, which is used to access the Unofficial Medium API.Medium
object, passing in an API key that is stored in an environmental variable named RAPIDAPI_KEY
. This object will be used to access the API.Medium
object to retrieve the article data from the API. This data is stored in an article
object.markdown
library to convert the article's Markdown content to HTML, and stores the result in a variable named html_output
.index.html
, replacing all occurrences of the ( ' ) character with a single quote.Overall, this code demonstrates how to use the medium_api
library to access the Unofficial Medium API and convert an article from Markdown to HTML. It is not a complete application but rather a sample of how the API can be used in a Python script.
Thanks for reading, and have a nice day!
PS: We post tutorials, videos, code snippets, and insights related to Medium and our API. So be sure to follow us on
Related Articles -