Public
Back
Version 142
7/7/2024
/** @jsx jsx */
import { jsx } from "https://deno.land/x/hono@v3.11.7/middleware.ts";
import { Hono } from "https://deno.land/x/hono@v3.11.7/mod.ts";
import { ai } from "https://esm.town/v/yawnxyz/ai";
import { getUrlMetadata } from "https://esm.town/v/yawnxyz/urlMetadata";
import { getHtmlMetadata } from "https://esm.town/v/yawnxyz/htmlMetadata";
import { getCitation } from "https://esm.town/v/yawnxyz/citation";
const app = new Hono();
export const getJinaContent = async (url, opts = {}) => {
const baseUrl = 'https://r.jina.ai/';
if (!url.includes('r.jina.ai')) {
url = baseUrl + url;
}
const fullUrl = new URL(url);
const headers = {
...(opts.withImagesSummary && { 'X-With-Images-Summary': 'true' }),
...(opts.withGeneratedAlt && { 'X-With-Generated-Alt': 'true' }),
...(opts.withLinksSummary && { 'X-With-Links-Summary': 'true' }),
...(opts.noCache && { 'X-No-Cache': 'true' }),
...(opts.accept && { 'Accept': opts.accept }),
...(opts.targetSelector && { 'X-Target-Selector': opts.targetSelector }),
...(opts.timeout && { 'X-Timeout': opts.timeout.toString() }),
...(opts.waitForSelector && { 'X-Wait-For-Selector': opts.waitForSelector }),
...(opts.returnFormat && { 'X-Return-Format': opts.returnFormat }),
};
console.log('[getJinaContent] Fetching:', fullUrl.toString(), headers);
try {
const response = await fetch(fullUrl.toString(), {
method: 'GET',
headers: headers,
});
yawnxyz-getcontentfromurl.web.val.run
Updated: August 24, 2024