import { Route } from '../../types/handlers'; import { Engine } from '../engine'; import { HandlerInput } from '../handler-input'; const SearXEngine = new Engine('SearX', ['searx.*']); async function search( input: HandlerInput, ro: Route<{ search: string; pageno?: string }> ) { const document = input.parseDom().window.document; const search = ro.q.search; const page = parseInt(ro.q.pageno || '1'); const page_footer = `${ page !== 1 ? `Previous |` : '' } Next`; const articles = Array.from(document.querySelectorAll('.result')); const articles_parsed = articles.map((a) => { const parsed = { url: (a.getElementsByClassName('url_wrapper')[0] as HTMLAnchorElement) .href || '', title: (a.getElementsByTagName('h3')[0] as HTMLHeadingElement).textContent || '', content: (a.getElementsByClassName('content')[0] as HTMLDivElement) .textContent || '', }; return { html: `${parsed.title}
${parsed.content}