IP

igorsaevets/page2ai-core

浏览器自动化

本页由 AI 翻译,技术细节请以原文为准。 查看原文

0 stars 0 forks 质量 66 趋势 20MIT

从任何网页HTML中提取干净的Markdown。Node.js(LinkedIn)+ 浏览器适配器。驱动Page2AI扩展和@page2ai/MCP服务器。

概览

用于大型语言模型上下文的网页到Markdown提取引擎(ChatGPT、Claude、Gemini)。驱动Page2AI Chrome和Firefox扩展及@page2ai/mcp服务器的同一引擎。保留带有语言提示、表格和阅读结构的代码块。零遥测,MIT授权。 它在Node.js(通过LinkedIn)和浏览器中都能正常工作。 - : htmlToMarkdown(html,选择)或fetchAndConvert(url,选择) — 零外部API调用,使用linkedom进行解析 - : 导出BrowserAdapter和PageAdapter接口;完整的提取流水线存储在扩展仓库(计划于v0.2迁移时) - : 无遥测、无分析、无第三方调用 - 授权 将HTML字符串转换为Markdown。同步。 - html(字符串)—— 解析的 HTML:完整文档或片段(HTMX 部分文件、模板摘要、纯文本)- opts.baseUrl(字符串)——用于解析相对链接的 URL(默认:'about:blank')——选择。

概述(AI 翻译)

用于大型语言模型上下文的网页到Markdown提取引擎(ChatGPT、Claude、Gemini)。 @page2ai/mcp 服务器的引擎。该 Page2AI Chrome 和 Firefox 扩展各自运行 浏览器中的流水线(见下文)。 保留带有语言提示、表格和阅读结构的代码块。 零遥测,MIT授权。

它在Node.js(通过LinkedIn)和浏览器中都能正常工作。

  • Node.js:htmlToMarkdown(html, opts) 或 fetchAndConvert(url, opts) — 零外部 API 调用,使用 Linkedom 进行解析
  • 浏览器:导出BrowserAdapter和PageAdapter接口;完整的提取流水线存储在扩展仓库中(计划进行迁移)
  • 零数据收集:无遥测,无分析,无第三方电话
  • MIT 持证

安装

快速开始

API

htmlToMarkdown(html, opts?)

将HTML字符串转换为Markdown。同步。

  • html(字符串)——解析的HTML:完整文档或片段(HTMX部分文件、模板摘要、纯文本)
  • opts.baseUrl(字符串)——用于解析相对链接的URL(默认:'about:blank')
  • ‘选择’。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

@page2ai/core

Webpage-to-Markdown extraction engine for LLM context (ChatGPT, Claude, Gemini). The engine of the @page2ai/mcp server. The Page2AI Chrome & Firefox extensions run their own pipeline in the browser (see below). Preserves code blocks with language hints, tables, and reading structure. Zero telemetry, MIT-licensed.

Works in Node.js (via linkedom) and in browsers.

  • Node.js: htmlToMarkdown(html, opts) or fetchAndConvert(url, opts) — zero external API calls, uses linkedom for parsing
  • Browser: exports BrowserAdapter and the PageAdapter interface; the full extract pipeline lives in the extension repo (a migration is planned)
  • Zero data collection: no telemetry, no analytics, no third-party calls
  • MIT licensed

Install

npm install @page2ai/core

Quick start

import { htmlToMarkdown, fetchAndConvert } from '@page2ai/core';

// From an HTML string
const html = `HelloWorld`;
const { markdown, title, charCount } = htmlToMarkdown(html, {
  baseUrl: 'https://example.com/hello',
  includeFrontmatter: true,
});
console.log(markdown);

// From a URL
const result = await fetchAndConvert('https://docs.anthropic.com/en/api/messages', {
  timeoutMs: 15000,
});
console.log(result.markdown);

API

htmlToMarkdown(html, opts?)

Converts an HTML string to Markdown. Synchronous.

  • html (string) — the HTML to parse: a whole document or a fragment (an HTMX partial, a template snippet, plain text)
  • opts.baseUrl (string) — URL used to resolve relative links (default: 'about:blank')
  • opts.profile (string) — accepted, but ignored by the Node build in this version: 'dashboard', 'marketing' and the rest produce the same output here. The profiles switch the browser extension’s live-page pipeline (clicking tabs, waiting for lazy content), which the Node renderer does not run
  • opts.includeFrontmatter (boolean) — emit YAML frontmatter block (default: true)
  • opts.includeImages (boolean) — emit image links (default: true). Inside a table cell, a layout table’s included, an image is written as its alt text either way, and an image with an empty alt or aria-hidden="true" adds nothing
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →