-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
7 changed files
with
115 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
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,29 @@ | ||
name: github pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-20.04 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup mdBook | ||
uses: peaceiris/actions-mdbook@v1 | ||
with: | ||
mdbook-version: 'latest' | ||
|
||
- run: cd book && mdbook build | ||
|
||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./book/book |
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 @@ | ||
book |
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,6 @@ | ||
[book] | ||
authors = ["j-mendez"] | ||
language = "en" | ||
multilingual = false | ||
src = "src" | ||
title = "spider-rs" |
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 @@ | ||
# Introduction | ||
|
||
Spider-RS is the fastest web crawler and indexer written in Rust. | ||
|
||
Spider powers some big tools and helps bring the crawling aspect to almost no downtime with the correct setup, view the [spider](https://github.com/spider-rs/spider) project to learn more. | ||
|
||
Node.js powerhouse crawling in a few lines! | ||
|
||
```ts | ||
import { Website } from "@spider-rs/spider-rs"; | ||
|
||
const website = new Website("https://rsseau.fr"); | ||
|
||
await website.crawl(); | ||
|
||
console.log(website.getLinks()); | ||
``` |
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 @@ | ||
# Summary | ||
|
||
[Introduction](./README.md) | ||
|
||
- [Node.js](./nodejs.md) |
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,54 @@ | ||
# Node.js | ||
|
||
We use the node-addon to port the Rust project over with napi to target node.js. | ||
|
||
There are some performance drawbacks from the addon, even still the crawls are lightning fast and performant. | ||
|
||
## Installation | ||
|
||
1. `npm i @spider-rs/spider-rs --save` | ||
|
||
## Usage | ||
|
||
The examples below can help get started with spider. | ||
|
||
### Basic | ||
|
||
A basic example. | ||
|
||
```ts | ||
import { Website } from "@spider-rs/spider-rs"; | ||
|
||
const website = new Website("https://rsseau.fr") | ||
.withHeaders({ | ||
authorization: "somerandomjwt", | ||
}) | ||
.withBudget({ | ||
// limit up to 200 pages crawled for the entire website | ||
"*": 200, | ||
}) | ||
.withBlacklistUrl([new RegExp("/books").source, "/resume"]) | ||
.build(); | ||
|
||
await website.crawl(); | ||
console.log(website.getLinks()); | ||
``` | ||
|
||
### Events | ||
|
||
You can pass a function that could be async as param to `crawl` and `scrape`. | ||
|
||
```ts | ||
import { Website, type NPage } from "@spider-rs/spider-rs"; | ||
|
||
const website = new Website("https://rsseau.fr"); | ||
|
||
const links: NPage[] = []; | ||
|
||
const onPageEvent = (err: Error | null, value: NPage) => { | ||
links.push(value); | ||
}; | ||
|
||
await website.crawl(onPageEvent); | ||
console.log(website.getLinks()); | ||
``` |