forked from langchain-ai/langchainjs
-
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.
Scrape all pages, not only level 1 navigation (langchain-ai#1191)
* Use sitemap to properly load all paths Gitbook's server-side rendering means that when we fetch the contents of the index page the sub-menu items are not rendered and thus are invisible to $('nav a'). This patch makes the loader use sitemap.xml which has an index of all pages. Inspired by the Python version. * Fix lint issues * Fix the logic * Add the integration test provided by jacoblee93 * Fix loading the docs * Fix formatting
- Loading branch information
Showing
2 changed files
with
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { test } from "@jest/globals"; | ||
import { GitbookLoader } from "../web/gitbook.js"; | ||
|
||
test("Test GitbookLoader", async () => { | ||
const loader = new GitbookLoader( | ||
"https://docs.gitbook.com/product-tour/navigation" | ||
); | ||
|
||
const docs = await loader.load(); | ||
console.log("Loaded", docs.length, "Gitbook documents"); | ||
}); | ||
|
||
test.only("Test GitbookLoader with shouldLoadAllPaths", async () => { | ||
const loader = new GitbookLoader("https://docs.maildrop.cc", { | ||
shouldLoadAllPaths: true, | ||
}); | ||
const docs = await loader.load(); | ||
console.log("Loaded", docs.length, "Gitbook documents"); | ||
}); |
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