medium-blogs-fetcher
Version:
A package to fetch Medium user profiles and blogs
46 lines (36 loc) ⢠1.62 kB
JavaScript
import {
getMediumUserProfile,
getMediumBlogs,
getMediumAvatar,
getTopUsersByTag,
} from "./index.js";
(async () => {
const tag = "technology"; // Change to any Medium tag you want to test
const limit = 5; // Set the limit to the desired number of top users
// console.log("š¹ Fetching Medium profile & blogs without options...");
// // Fetch without options (default request)
// const profileDefault = await getMediumUserProfile("startswithabang");
// console.log("š¹ Default Profile:", profileDefault);
const blogsDefault = await getMediumBlogs("codingoni");
// console.log("š¹ Default Blogs:", blogsDefault);
// console.log("\nš¹ Fetching with custom headers & proxy...");
const usersWithoutOptions = await getTopUsersByTag(tag, limit);
console.log("š¹ Top Users (Limited):", usersWithoutOptions);
// // Options with custom headers & proxy
const options = {
headers: {
"User-Agent": "Mozilla/5.0",
Authorization: "Bearer YOUR_TOKEN_HERE", // Optional API key or token
},
proxy: {
host: "123.45.67.89",
port: 8080,
}, // Example proxy settings (remove if not needed)
};
// const profileWithOptions = await getMediumUserProfile("codingoni", options);
// console.log("š¹ Profile with Options:", profileWithOptions);
// const blogsWithOptions = await getMediumBlogs("codingoni", options);
// console.log("š¹ Blogs with Options:", blogsWithOptions);
// const avatarWithOptions = await getMediumAvatar("codingoni", options);
// console.log("š¹ Avatar with Options:", avatarWithOptions);
})();