Initialize project structure with Bun, Elysia, and AI-powered article summarization
This commit is contained in:
21
bak/rss.js
Normal file
21
bak/rss.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// ... existing code ...
|
||||
export async function fetchRSS(url, maxRetries = 3) {
|
||||
let retries = 0;
|
||||
while (retries < maxRetries) {
|
||||
try {
|
||||
const response = await fetch(url, { verbose: true, keepalive: true, timeout: 10000, compress: false });
|
||||
// console.log('Response:', response);
|
||||
const text = await response.text();
|
||||
// console.log('Response Text:', text);
|
||||
return text;
|
||||
} catch (error) {
|
||||
console.error(`Fetch Error (Attempt ${retries + 1}):`, error);
|
||||
retries++;
|
||||
// 等待一段时间再重试,避免过于频繁的请求
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
console.error('Fetch failed after multiple retries.');
|
||||
return null;
|
||||
}
|
||||
// ... existing code ...
|
||||
Reference in New Issue
Block a user