没有好的资源,爬了一些bing的壁纸 做成了随机api 图片链接上传用的是坛子里分享的诈骗图床 演示:imgs.810088.xyz cf worker: addEventListener(‘fetch’, (event) => { event.respondWith(handleRequest(event.request)) }) async function handleRequest(request) { const response = await fetch(‘https://raw.githubusercontent.com/duansix/cftts_temple/main/bing.txt’) // 替换为您的文本文件链接 if (!response.ok) { return new Response(‘Failed to fetch the image links.’, { status: 500 }) } const text = await response.text() const imageLinks = text.trim().split(‘\n’) if (imageLinks.length === 0) { return new Response(‘No image links found.’, { status: 404 }) } const randomIndex = Math.floor(Math.random() * imageLinks.length) const imageUrl = imageLinks[randomIndex].trim() const imageResponse = await fetch(imageUrl) if (!imageResponse.ok) { return new Response(`Failed to fetch the image at ${imageUrl}.`, { status: 500 }) } const headers = { ‘Content-Type’: imageResponse.headers.get(‘Content-Type’), ‘Cache-Control’: ‘public, max-age=3600’, // 可根据需要设置缓存策略 } return new Response(imageResponse.body, { headers }) } 复制代码
没有回复内容