-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss2.html
79 lines (71 loc) · 2.36 KB
/
rss2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RSS Feed Example</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
#rss-container {
background-color: #ffffff;
border-radius: 10px;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
font-family: Arial, sans-serif;
}
ul {
list-style: none;
padding: 0;
}
li {
margin-bottom: 10px;
}
a {
text-decoration: none;
color: #0070c9;
}
</style>
</head>
<body>
<div id="rss-container">
<h2>RSS Feed</h2>
<div id="rss-feed"></div>
</div>
<script>
var rssToJsonApi = 'https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fwww.ruv.is%2Frss%2Ffrettir';
var rssFeedContainer = document.getElementById('rss-feed');
// Function to fetch and display the RSS feed
function fetchAndDisplayRssFeed() {
fetch(rssToJsonApi)
.then(response => response.json())
.then(data => {
// Check if the data has items
if (data.items && data.items.length > 0) {
// Create an HTML string to display the feed
var html = '<ul>';
data.items.forEach(item => {
html += `<li><a href="${item.link}" target="_blank">${item.title}</a></li>`;
});
html += '</ul>';
// Insert the HTML into the rss-feed container
rssFeedContainer.innerHTML = html;
} else {
rssFeedContainer.innerHTML = 'No RSS feed items found.';
}
})
.catch(error => {
rssFeedContainer.innerHTML = 'Error fetching RSS feed: ' + error.message;
});
}
// Call the function to fetch and display the RSS feed
fetchAndDisplayRssFeed();
</script>
</body>
</html>