-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dd13f19
Showing
10 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.git*/** | ||
.idea/** | ||
.vscode/** | ||
benchmarks/** | ||
eggs-debug.log | ||
.github | ||
LICENSE | ||
deno.json | ||
.vscode | ||
.gitignore | ||
test.ts | ||
score.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Test Scrape | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Clone repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Deno environment | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Setup Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.deno | ||
~/.cache/deno | ||
key: ${{ runner.os }}-deno-${{ hashFiles('**/_config.ts', '**/import_map.json') }} | ||
|
||
- name: Running Tools | ||
run: | | ||
deno run --allow-net --allow-read test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_cache | ||
eggs-debug.log | ||
score.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2022 Santhosh Veer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": true, | ||
"deno.suggest.imports.hosts": { | ||
"https://deno.land": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Deno Cheerio | ||
|
||
[](https://github.com/mskian/deno-cheerio-js/actions/workflows/test.yml) | ||
 | ||
|
||
Cheerio - Porting Cheerio Node Module To Deno using `esm.sh` | ||
|
||
## Prerequisites | ||
|
||
- Deno on your System <https://deno.land/#installation> | ||
|
||
## Usage | ||
|
||
- Cheerio Full Docs and usage - <https://cheerio.js.org/> | ||
|
||
```js | ||
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 | ||
|
||
```sh | ||
deno run --allow-net --allow-read test.ts | ||
|
||
or | ||
|
||
deno task test | ||
``` | ||
|
||
## Credits | ||
|
||
- cheerio Npm Module - <https://github.com/cheeriojs/cheerio> | ||
|
||
## LICENSE | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tasks": { | ||
"test": "deno run --allow-net --allow-read test.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "https://x.nest.land/eggs@0.3.10/src/schema.json", | ||
"name": "cheerio", | ||
"entry": "./mod.ts", | ||
"description": "Cheerio - Porting Cheerio Node Module To Deno", | ||
"homepage": "https://github.com/mskian/deno-cheerio-js", | ||
"version": "0.0.1", | ||
"releaseType": null, | ||
"unstable": false, | ||
"unlisted": false, | ||
"files": [ | ||
"README.md" | ||
], | ||
"ignore": [ | ||
".git", | ||
".github", | ||
"LICENSE", | ||
"deno.json", | ||
".vscode", | ||
".gitignore", | ||
"test.ts", | ||
"score.ts" | ||
], | ||
"checkFormat": "deno fmt", | ||
"checkTests": false, | ||
"checkInstallation": false, | ||
"check": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Deno Cheerio | ||
* Cheerio - Porting Cheerio Node Module To Deno | ||
* Convert using - https://esm.sh/ | ||
*/ | ||
|
||
import * as cheerio from "https://esm.sh/cheerio@1.0.0-rc.12"; | ||
|
||
export { cheerio }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { cheerio } from "./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); | ||
}); |