웹사이트 스크래퍼
웹사이트를 스크래핑하고 HTML을 마크다운으로 변환하는 명령줄 도구이자 MCP 서버입니다.
특징
Mozilla의 Readability 라이브러리(Firefox의 Reader View에서 사용되는 것과 동일한 엔진)를 사용하여 웹 페이지에서 의미 있는 콘텐츠를 추출합니다.
TurndownService를 사용하여 깨끗한 HTML을 고품질 Markdown으로 변환합니다.
잠재적으로 유해한 스크립트 태그를 제거하여 HTML을 안전하게 처리합니다.
명령줄 도구와 MCP 서버로 모두 작동합니다.
로컬 HTML 파일을 Markdown으로 직접 변환하는 기능을 지원합니다.
Related MCP server: MCP Server Fetch Python
설치
지엑스피1
용법
CLI 모드
# Print output to console
scrape https://example.com
# Save output to a file
scrape https://example.com output.md
# Convert a local HTML file to Markdown
scrape --html-file input.html
# Convert a local HTML file and save output to a file
scrape --html-file input.html output.md
# Show help
scrape --help
# Or run via npm script
npm run start:cli -- https://example.com
MCP 서버 모드
이 도구는 MCP(Model Context Protocol) 서버로 사용할 수 있습니다.
# Start in MCP server mode
npm start
코드 구조
src/index.ts- 핵심 기능 및 MCP 서버 구현src/cli.ts- 명령줄 인터페이스 구현src/data_processing.ts- HTML을 마크다운으로 변환하는 기능
API
이 도구는 다음 기능을 내보냅니다.
// Scrape a website and convert to Markdown
import { scrapeToMarkdown } from './build/index.js';
// Convert HTML string to Markdown directly
import { htmlToMarkdown } from './build/data_processing.js';
async function example() {
// Web scraping
const markdown = await scrapeToMarkdown('https://example.com');
console.log(markdown);
// Direct HTML conversion
const html = '<h1>Hello World</h1><p>This is <strong>bold</strong> text.</p>';
const md = htmlToMarkdown(html);
console.log(md);
}
특허
아이에스씨