Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Merge branch 'main' into bug/crawl-limit

rafaelsideguidef4a3469b9ea4
diff --cc apps/api/src/scraper/WebScraper/crawler.ts
index 1b371fdc3,adfd435af..9340aa8c5
--- a/apps/api/src/scraper/WebScraper/crawler.ts
+++ b/apps/api/src/scraper/WebScraper/crawler.ts
@@@ -133,10 -149,10 +149,10 @@@ export class WebCrawler
private async crawlUrls(
urls: string[],
concurrencyLimit: number,
- inProgress?: (progress: Progress) => void
- ): Promise<string[]> {
+ inProgress?: (progress: Progress) => void,
+ ): Promise<{ url: string, html: string }[]> {
const queue = async.queue(async (task: string, callback) => {
- if (this.crawledUrls.size >= this.maxCrawledLinks) {
+ if (this.crawledUrls.size >= Math.min(this.maxCrawledLinks, this.limit)) {
if (callback && typeof callback === "function") {
callback();
}
@@@ -147,9 -176,9 +176,9 @@@
if (inProgress && newUrls.length > 0) {
inProgress({
current: this.crawledUrls.size,
- total: this.maxCrawledLinks,
+ total: Math.min(this.maxCrawledLinks, this.limit),
status: "SCRAPING",
- currentDocumentUrl: newUrls[newUrls.length - 1],
+ currentDocumentUrl: newUrls[newUrls.length - 1].url,
});
} else if (inProgress) {
inProgress({