0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
The whole point of the gator
program is to fetch the RSS feed of a website and store its content in a structured format in our database. That way we can display it nicely in our CLI.
RSS stands for "Really Simple Syndication" and is a way to get the latest content from a website in a structured format. It's fairly ubiquitous on the web: most content sites have an RSS feed.
RSS is a specific structure of XML (I know, gross). We will keep it simple and only worry about a few fields. Here's an example of the documents we'll parse:
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>RSS Feed Example</title>
<link>https://www.example.com</link>
<description>This is an example RSS feed</description>
<item>
<title>First Article</title>
<link>https://www.example.com/article1</link>
<description>This is the content of the first article.</description>
<pubDate>Mon, 06 Sep 2021 12:00:00 GMT</pubDate>
</item>
<item>
<title>Second Article</title>
<link>https://www.example.com/article2</link>
<description>Here's the content of the second article.</description>
<pubDate>Tue, 07 Sep 2021 14:30:00 GMT</pubDate>
</item>
</channel>
</rss>
We'll then then parse this kind of document into a JavaScript objects like this:
type RSSFeed = {
channel: {
title: string;
link: string;
description: string;
item: RSSItem[];
};
};
type RSSItem = {
title: string;
link: string;
description: string;
pubDate: string;
};
If our program were running in a browser, we could use the built-in DOMParser
API, but since we're in Node.js, we'll use fast-xml-parser
instead.
npm i fast-xml-parser
Run and submit the CLI tests.
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run 29c20abd-16d5-4c8c-866a-b8c9b9842cca
Submit
bootdev run 29c20abd-16d5-4c8c-866a-b8c9b9842cca -s
Run the CLI commands to test your solution.
Login to view solution
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.