-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.html
77 lines (67 loc) · 2.78 KB
/
environment.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
<!DOCTYPE html>
<html>
<head>
<title>News from Times of India</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Merriweather">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora">
<link rel="stylesheet" href="app-css.css" type="text/css">
<style>
/* CSS styles for article elements */
.article {
margin-bottom: 20px;
}
.article h2 {
font-size: 24px;
margin-bottom: 5px;
}
.article p {
margin-bottom: 10px;
}
.article a {
display: block;
font-size: 14px;
}
</style>
</head>
<body>
<div id="top-panel">The Times of ASME</div>
<hr>
<div id="nav-panel">
<a class="type" href="top-stories.html">Top Stories</a><a class="type" href="sports.html">Sports</a><a class="type" href="science.html">Science</a>
<a class="type" href="environment.html" style="background-color: #696969 !important; color:#fff !important">Environment</a><a class="type" href="technology.html">Technology</a><a class="type" href="entertainment.html">Entertainment</a>
</div>
<hr>
<div id ='top'><div id="news-container"></div></div>
<script>
fetch('https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Ftimesofindia.indiatimes.com%2Frssfeeds%2F2647163.cms')
.then(response => response.json())
.then(data => {
const newsContainer = document.getElementById('news-container');
const articles = data.items;
articles.forEach(article => {
const title = article.title;
const description = article.description;
const link = article.link;
const image = article.enclosure.link;
const articleDiv = document.createElement('div');
articleDiv.classList.add('article');
const titleElement = document.createElement('h2');
titleElement.textContent = title;
descriptionElement = document.createElement('p');
// descriptionElement.textContent = description;
const linkElement = document.createElement('a');
linkElement.href = link;
linkElement.textContent = '...Read more';
const imageElement = document.createElement('img');
imageElement.src = image;
articleDiv.appendChild(titleElement);
articleDiv.appendChild(descriptionElement);
descriptionElement.appendChild(linkElement); //append link to description
articleDiv.appendChild(imageElement);
newsContainer.appendChild(articleDiv);
});
})
.catch(error => console.log(error));
</script>
</body>
</html>