Skip to content

mskian/deno-cheerio-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno Cheerio

Test Scrape Deno

Cheerio - Porting Cheerio Node Module To Deno using esm.sh

Prerequisites

Usage

import { cheerio } from "https://deno.land/x/denocheerio/mod.ts";

fetch(
  "https://notes.santhoshveer.com/",
)
  .then((result) => result.text())
  .then((html) => {
    const $ = cheerio.load(html);
    const title = $('meta[property="og:title"]').attr("content") ||
      $("title").text() || $('meta[name="title"]').attr("content");
    const description = $('meta[property="og:description"]').attr("content") ||
      $('meta[name="description"]').attr("content");
    console.log(title);
    console.log(description);
  }).catch((error) => {
    console.log(error);
  });

Testing

deno run --allow-net --allow-read test.ts

or

deno task test

Credits

LICENSE

MIT