Skip to content

Instantly share code, notes, and snippets.

@mikestaub
Created March 10, 2024 16:18
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 mikestaub/322c0ebcd76ae0d6f3dae635accacd60 to your computer and use it in GitHub Desktop.
Save mikestaub/322c0ebcd76ae0d6f3dae635accacd60 to your computer and use it in GitHub Desktop.
zapier top hacker news
const fetchRssFeed = async () => {
const response = await fetch(
"https://hnrss.org/frontpage?points=100&count=10"
);
const text = await response.text();
const items = text.split("<item>").slice(1);
return items.map((item) => {
let title = item.match(/<title>(.*?)<\/title>/)[1];
title = title.replace("<![CDATA[", "").replace("]]>", "");
const comments = item.match(/<comments>(.*?)<\/comments>/)[1];
const html = "<a href=" + comments + ">" + title + "</a></br></br>";
return {
title,
comments,
html,
};
});
};
const result = await fetchRssFeed();
output = result;
return { items: result };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment