-
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.
chore(docs): add full website config examples
- Loading branch information
Showing
5 changed files
with
156 additions
and
6 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
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,46 @@ | ||
# Crawl | ||
|
||
Crawl a website concurrently. | ||
|
||
```ts | ||
import { Website } from "@spider-rs/spider-rs"; | ||
|
||
// pass in the website url | ||
const website = new Website("https://rsseau.fr"); | ||
|
||
await website.crawl(); | ||
console.log(website.getLinks()); | ||
``` | ||
|
||
## Async Event | ||
|
||
You can pass in a async function as the first param to the crawl function for realtime updates streamed. | ||
|
||
```ts | ||
import { Website } from "@spider-rs/spider-rs"; | ||
|
||
const website = new Website("https://rsseau.fr"); | ||
|
||
const onPageEvent = (err, value) => { | ||
console.log(value); | ||
}; | ||
|
||
await website.crawl(onPageEvent); | ||
``` | ||
|
||
## Background | ||
|
||
You can run the request in the background and receive events with the second param set to `true`. | ||
|
||
```ts | ||
import { Website } from "@spider-rs/spider-rs"; | ||
|
||
const website = new Website("https://rsseau.fr"); | ||
|
||
const onPageEvent = (err, value) => { | ||
console.log(value); | ||
}; | ||
|
||
await website.crawl(onPageEvent, true); | ||
// this will run instantly as the crawl is in the background | ||
``` |
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