Skip to content

Instantly share code, notes, and snippets.

@weeping-angel
Last active March 4, 2024 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weeping-angel/ae1f46c117a69428218beb74fc641c3e to your computer and use it in GitHub Desktop.
Save weeping-angel/ae1f46c117a69428218beb74fc641c3e to your computer and use it in GitHub Desktop.
[Get Publication Articles] Code to get recently published articles on a Medium Publication. #python #medium_api #medium_api_py
# Import libraries
import os
from datetime import datetime, timedelta
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Create a "Publication" Object
publication = medium.publication(publication_id="98111c9905da", save_info=False)
# Fetch publication articles published within last week's days
last_weeks_articles = publication.get_articles_between(
_from=datetime.now(),
_to=datetime.now() - timedelta(days=7)
)
for article in last_weeks_articles:
print(article.title, f'({article.published_at})')
# Import libraries
import os
from datetime import datetime, timedelta
from medium_api import Medium
# Get RAPIDAPI_KEY from the environment
api_key = os.getenv('RAPIDAPI_KEY')
# Create a `Medium` Object
medium = Medium(api_key)
# Create a "Publication" Object
publication = medium.publication(publication_id="98111c9905da", save_info=False)
# Fetch publication articles published within last week's days
last_weeks_articles = publication.get_articles_between(
_from=datetime.now(),
_to=datetime.now() - timedelta(days=7)
)
for article in last_weeks_articles:
print(article.title, f'({article.published_at})')
Google’s New AI Model PaLM-E Explained (2023-03-28 18:01:42)
Rustic Learning: Machine Learning in Rust — Part 1: Introduction to Rust (2023-04-02 16:01:44)
Supercharge Your Productivity 11 AI-Powered Tools You Need to Try Today (2023-04-02 20:01:44)
Pandas Cheat Sheet: Functions for Data Analysis (2023-03-31 22:01:44)
K-Nearest Neighbors from scratch (2023-03-31 20:01:42)
How to List, Read, Upload, and Delete Files in Azure Blob Storage With Python. (2023-03-29 14:01:45)
The Power of Words: Mastering Prompt Engineering for AI Models (2023-03-29 22:02:04)
Efficient Strategies for Effective Stable Diffusion Prompt: A Comprehensive Guide (2023-03-31 16:01:45)
.
.
.
Python for Natural Language Processing: A Beginner’s Guide (2023-03-27 22:02:03)
10 Best Python Libraries for Machine Learning and AI (2023-03-27 13:59:13)
Meet MM-REACT: Microsoft Research New Model that Enables Visual Reasoning on top of ChatGPT (2023-03-27 12:31:27)
How to Build a Low-Code Sales Dashboard with Python and Deepnote (2023-03-28 16:01:45)
A Comprehensive Introduction to Machine Learning Experiment Tracking (2023-03-27 20:01:40)
AI Won’t Replace Marketers, But It Will Help Them Succeed (2023-03-28 00:02:02)
How ChatGPT Changed the Way I Approach Problem-Solving (2023-03-27 18:01:44)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment