r6-data.js 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,7 +21,7 @@ npm install r6-data.js
21
21
  npm i r6-data.js
22
22
  ```
23
23
 
24
- ## Last updated Y10S3
24
+ ### Last updated Y10S3
25
25
 
26
26
  ## Getting Player Stats and Account Information
27
27
 
@@ -110,6 +110,57 @@ You can filter these statistics by game mode using the `board_id` parameter:
110
110
  - `standard`: Statistics for standard matches
111
111
  - `ranked`: Statistics for ranked competitive matches
112
112
 
113
+ ## Getting Latest Siege News
114
+ The `getLatestSiegeNews()` function allows you to retrieve the latest news and articles from Rainbow Six Siege.
115
+
116
+ ```javascript
117
+ const r6Info = require('r6-data.js');
118
+
119
+ async function main() {
120
+ try {
121
+ // Get latest Siege news
122
+ const siegeNews = await r6Info.getLatestSiegeNews();
123
+ console.log('Siege News:', siegeNews);
124
+
125
+ // Access featured articles
126
+ console.log('Featured Articles:', siegeNews.featuredArticles);
127
+
128
+ // Access latest articles
129
+ console.log('Latest Articles:', siegeNews.latestArticles);
130
+
131
+ // Display individual article information
132
+ siegeNews.featuredArticles.forEach(article => {
133
+ console.log(`Title: ${article.title}`);
134
+ console.log(`Link: ${article.link}`);
135
+ console.log(`Type: ${article.type}`);
136
+ console.log(`Scraped at: ${article.scrapedAt}`);
137
+ console.log('---');
138
+ });
139
+
140
+ } catch (error) {
141
+ console.error('Error while fetching Siege news:', error.message);
142
+ }
143
+ }
144
+
145
+ main();
146
+ ```
147
+
148
+ ### News Response Structure
149
+ The function returns an object containing:
150
+
151
+ `featuredArticles`: Array of up to 5 featured articles from siege.gg
152
+ `latestArticles`: Array of up to 10 latest articles from siege.gg
153
+ `scrapedAt`: Timestamp indicating when the data was retrieved
154
+
155
+ Each article object contains:
156
+
157
+ `title`: The article title (cleaned from "Siege" suffix)
158
+ `imageUrl`: URL of the article's featured image
159
+ `link`: Full URL to the article
160
+ `type`: Article type ("featured" or "latest")
161
+ `category`: Article category (for latest articles: "news" or "general")
162
+ `scrapedAt`: Timestamp of when the article was scraped
163
+
113
164
  ## Searching Across All Entities
114
165
 
115
166
  The `getSearchAll()` function allows you to search across all Rainbow Six Siege entities (operators, weapons, maps, seasons, charms, and attachments) with a single query. This is useful for finding relevant information across multiple categories at once.
package/index.js CHANGED
@@ -9,6 +9,7 @@ const getWeapons = require('./methods/getWeapons');
9
9
  const getUniversalSkins = require('./methods/getUniversalSkins');
10
10
  const getSearchAll = require('./methods/getSearchAll');
11
11
  const getStats = require('./methods/getStats');
12
+ const getLatestSiegeNews = require('./methods/getLatestSiegeNews');
12
13
 
13
14
  const r6Data = {
14
15
  getMaps,
@@ -22,6 +23,7 @@ const r6Data = {
22
23
  getUniversalSkins,
23
24
  getSearchAll,
24
25
  getStats,
26
+ getLatestSiegeNews,
25
27
  };
26
28
 
27
29
  module.exports = r6Data;
@@ -0,0 +1,60 @@
1
+ const cheerio = require('cheerio');
2
+
3
+ async function getLatestSiegeNews() {
4
+ try {
5
+ const response = await fetch('https://siege.gg/');
6
+ const html = await response.text();
7
+ const $ = cheerio.load(html);
8
+
9
+ const featuredArticles = [];
10
+ const latestArticles = [];
11
+
12
+ // Estrae Featured Articles
13
+ $('h2:contains("Featured Articles")').parent().find('a').each((index, article) => {
14
+ const title = $(article).find('img').attr('alt') || '';
15
+ const imageUrl = $(article).find('img').attr('src') || '';
16
+ const link = $(article).attr('href') || '';
17
+
18
+ if (title && link) {
19
+ featuredArticles.push({
20
+ title: title.replace(' Siege', '').trim(),
21
+ imageUrl,
22
+ link: link.startsWith('http') ? link : `https://siege.gg${link}`,
23
+ type: 'featured',
24
+ scrapedAt: new Date().toISOString()
25
+ });
26
+ }
27
+ });
28
+
29
+ // Estrae Latest Articles
30
+ $('h2:contains("Latest Articles")').parent().find('a').each((index, article) => {
31
+ const title = $(article).find('img').attr('alt') || '';
32
+ const imageUrl = $(article).find('img').attr('src') || '';
33
+ const link = $(article).attr('href') || '';
34
+ const category = $(article).text().includes('News') ? 'news' : 'general';
35
+
36
+ if (title && link) {
37
+ latestArticles.push({
38
+ title: title.replace(' Siege', '').trim(),
39
+ imageUrl,
40
+ link: link.startsWith('http') ? link : `https://siege.gg${link}`,
41
+ category,
42
+ type: 'latest',
43
+ scrapedAt: new Date().toISOString()
44
+ });
45
+ }
46
+ });
47
+
48
+ return {
49
+ featuredArticles: featuredArticles.slice(0, 5),
50
+ latestArticles: latestArticles.slice(0, 10),
51
+ scrapedAt: new Date().toISOString()
52
+ };
53
+
54
+ } catch (error) {
55
+ console.error('Error fetching siege news:', error.message);
56
+ throw new Error(`Error fetching siege news: ${error.message}`);
57
+ }
58
+ }
59
+
60
+ module.exports = getLatestSiegeNews;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "r6-data.js",
3
- "version": "1.0.2",
4
- "description": "A wrapper for the Rainbow Six Siege API that gives you information about player's stats, maps, operators, ranks, seasons, charms etc",
3
+ "version": "1.1.0",
4
+ "description": "A wrapper for Rainbow Six Siege API that gives you information about player's stats, maps, operators, ranks, seasons, charms etc",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -44,7 +44,8 @@
44
44
  "author": "mazeor",
45
45
  "license": "ISC",
46
46
  "dependencies": {
47
- "axios": "^1.9.0",
47
+ "axios": "^1.11.0",
48
+ "cheerio": "^1.1.0",
48
49
  "ms": "^2.1.3"
49
50
  },
50
51
  "devDependencies": {