Simple usage
October 19, 2024 by
The simplest way to use Webforai
Install dependencies
Install the necessary packages:
npm
npm init -y
npm install webforai
npm install -D tsx
Write code
Here’s how to convert HTML to Markdown using webforai:
src/index.ts
import { htmlToMarkdown } from "webforai";
import { loadHtml } from "webforai/loaders/fetch";
const html = await loadHtml("https://example.com");
const markdown = htmlToMarkdown(html);
console.log(markdown);
Launch
tsx src/index.ts
# => # Example Domain
# =>
# => This domain is for use in illustrative examples in documents. You may use this
# => domain in literature without prior coordination or asking for permission.
# =>
# => More information...