34 }
35 // Do not await the response
36 fetch(`${httpEndpoint}/event?name=import-init&val=${runningValInfo.author}/${runningValInfo.name}`);
37 } catch (e) {
38 console.error(`Error initializing analytics: ${e}`);
45 const runningValInfo = getRunningValInfo();
46 return async (req: Request): Promise<Response> => {
47 fetch(`${httpEndpoint}/event?name=request&val=${runningValInfo.author}/${runningValInfo.name}&url=${req.url}`);
48 return handler(req);
49 };
11
12const app = new Hono();
13export default app.fetch;
14app.get("/", async (c) => {
15 const vals = await sqlite.execute(
10 data.append("file", file);
11
12 const res = await fetch("https://api.pinata.cloud/pinning/pinFileToIPFS", {
13 method: "POST",
14 headers: {
9 let reason: string;
10 try {
11 const res = await fetch(URL, { redirect: "follow" });
12 if (res.status !== 200) {
13 reason = `(status code: ${res.status})`;
15 }
16 } catch (e) {
17 reason = `couldn't fetch: ${e}`;
18 ok = false;
19 }
27 ];
28
29 const response = await fetch(endpoint, {
30 method: 'POST',
31 headers: {
48 );
49});
50export default app.fetch;
21
22 if (cacheData && cacheData.expiration > Date.now()) {
23 return new Response((await fetch(cacheData.url)).body, { headers: { "content-type": "image/jpg" } });
24 }
25
30 await blob.setJSON(genKey(key), { url, expiration });
31
32 return new Response((await fetch(url)).body, {
33 headers: {
34 "content-type": "image/jpg",
19export default async function(req: Request): Promise<Response> {
20 const url = new URL(`https://atelierharfang.ch`);
21 const html = await fetch(url.toString(), {
22 method: req.method,
23 headers: new Headers({
26 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
27 "Accept-Language": "en-US,en;q=0.5",
28 "Sec-Fetch-Site": "cross-site",
29 "Sec-Fetch-Mode": "navigate",
30 "Sec-Fetch-User": "?1",
31 "Sec-Fetch-Dest": "document",
32 "Referer": "https://www.google.com/",
33 "sec-ch-ua": `"Not A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"`,
17export default async function(req: Request): Promise<Response> {
18 const url = new URL(`https://tanstack.com/blog`);
19 const html = await fetch(url.toString(), {
20 method: req.method,
21 headers: new Headers({
24 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
25 "Accept-Language": "en-US,en;q=0.5",
26 "Sec-Fetch-Site": "cross-site",
27 "Sec-Fetch-Mode": "navigate",
28 "Sec-Fetch-User": "?1",
29 "Sec-Fetch-Dest": "document",
30 "Referer": "https://www.google.com/",
31 "sec-ch-ua": `"Not A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"`,
1import { fetch } from "https://esm.town/v/std/fetch";
2
3// Define a type for the results that will be fetched
4type FeedResult = {
5 url: string;
8};
9
10// Fetch the HTML content of the given URL
11async function fetchHtml(url: string): Promise<string> {
12 const response = await fetch(url, {
13 method: "GET",
14 headers: {
24
25 if (!response.ok) {
26 throw new Error(`Failed to fetch URL: ${url} - Status: ${response.status}`);
27 }
28
63 try {
64 const cacheBustingUrl = `${feedUrl}×tamp=${new Date().getTime()}`;
65 const response = await fetch(cacheBustingUrl, {
66 method: "GET",
67 headers: {
77
78 if (!response.ok) {
79 console.error(`Failed to fetch URL: ${feedUrl} - Status: ${response.status}`);
80 continue;
81 }
86 }
87 } catch (error) {
88 console.error(`Error fetching URL: ${feedUrl}`, error);
89 }
90 }
98 const baseUrl = "https://forums.spacebattles.com/search/69363141/?t=post&c[content]=thread&c[users]=3ndless&o=date";
99 try {
100 const html = await fetchHtml(baseUrl);
101 const titles = titleExtractor(html);
102 const feeds = titles.flatMap(urlGenerator);
132 return totalWords;
133 } catch (error) {
134 console.error(`Failed to fetch or parse RSS feed from ${url}:`, error);
135 return null;
136 }
152 //console.log("Useful URLs:", usefulUrls); // Debugging log
153 //return usefulUrls;
154 const wordcount = await fetchAndExtractWordCount(usefulUrls); // Extract word count
155 console.log("Final Word Counts:", wordcount); // Debugging log
156 return wordcount;