@crawlee/basic 3.17.1-beta.4 → 3.17.1-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -719,5 +719,6 @@ interface HandlePropertyNameChangeData<New, Old> {
|
|
|
719
719
|
* await crawler.run();
|
|
720
720
|
* ```
|
|
721
721
|
*/
|
|
722
|
-
export declare function createBasicRouter<Context extends BasicCrawlingContext = BasicCrawlingContext,
|
|
722
|
+
export declare function createBasicRouter<Context extends BasicCrawlingContext = BasicCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
|
|
723
|
+
export declare function createBasicRouter<Context extends BasicCrawlingContext = BasicCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
|
|
723
724
|
export {};
|
|
@@ -688,8 +688,12 @@ class BasicCrawler {
|
|
|
688
688
|
finished = true;
|
|
689
689
|
}
|
|
690
690
|
periodicLogger.stop();
|
|
691
|
-
//
|
|
692
|
-
|
|
691
|
+
// Give the event loop a single tick to flush the HTTP
|
|
692
|
+
// 1ms is enough because we already have a keep-alive connection to the API
|
|
693
|
+
await Promise.race([
|
|
694
|
+
this.setStatusMessage(`Finished! Total ${this.stats.state.requestsFinished + this.stats.state.requestsFailed} requests: ${this.stats.state.requestsFinished} succeeded, ${this.stats.state.requestsFailed} failed.`, { isStatusMessageTerminal: true, level: 'INFO' }),
|
|
695
|
+
(0, utils_1.sleep)(1),
|
|
696
|
+
]);
|
|
693
697
|
this.running = false;
|
|
694
698
|
this.hasFinishedBefore = true;
|
|
695
699
|
}
|
|
@@ -1502,30 +1506,6 @@ Object.defineProperty(BasicCrawler, "optionsShape", {
|
|
|
1502
1506
|
statisticsOptions: ow_1.default.optional.object,
|
|
1503
1507
|
}
|
|
1504
1508
|
});
|
|
1505
|
-
/**
|
|
1506
|
-
* Creates new {@link Router} instance that works based on request labels.
|
|
1507
|
-
* This instance can then serve as a {@link BasicCrawlerOptions.requestHandler|`requestHandler`} of our {@link BasicCrawler}.
|
|
1508
|
-
* Defaults to the {@link BasicCrawlingContext}.
|
|
1509
|
-
*
|
|
1510
|
-
* > Serves as a shortcut for using `Router.create<BasicCrawlingContext>()`.
|
|
1511
|
-
*
|
|
1512
|
-
* ```ts
|
|
1513
|
-
* import { BasicCrawler, createBasicRouter } from 'crawlee';
|
|
1514
|
-
*
|
|
1515
|
-
* const router = createBasicRouter();
|
|
1516
|
-
* router.addHandler('label-a', async (ctx) => {
|
|
1517
|
-
* ctx.log.info('...');
|
|
1518
|
-
* });
|
|
1519
|
-
* router.addDefaultHandler(async (ctx) => {
|
|
1520
|
-
* ctx.log.info('...');
|
|
1521
|
-
* });
|
|
1522
|
-
*
|
|
1523
|
-
* const crawler = new BasicCrawler({
|
|
1524
|
-
* requestHandler: router,
|
|
1525
|
-
* });
|
|
1526
|
-
* await crawler.run();
|
|
1527
|
-
* ```
|
|
1528
|
-
*/
|
|
1529
1509
|
function createBasicRouter(routes) {
|
|
1530
1510
|
return core_1.Router.create(routes);
|
|
1531
1511
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/basic",
|
|
3
|
-
"version": "3.17.1-beta.
|
|
3
|
+
"version": "3.17.1-beta.40",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -45,12 +45,13 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
+
"@apify/datastructures": "^2.0.0",
|
|
48
49
|
"@apify/log": "^2.4.0",
|
|
49
50
|
"@apify/timeout": "^0.3.0",
|
|
50
51
|
"@apify/utilities": "^2.7.10",
|
|
51
|
-
"@crawlee/core": "3.17.1-beta.
|
|
52
|
-
"@crawlee/types": "3.17.1-beta.
|
|
53
|
-
"@crawlee/utils": "3.17.1-beta.
|
|
52
|
+
"@crawlee/core": "3.17.1-beta.40",
|
|
53
|
+
"@crawlee/types": "3.17.1-beta.40",
|
|
54
|
+
"@crawlee/utils": "3.17.1-beta.40",
|
|
54
55
|
"csv-stringify": "^6.2.0",
|
|
55
56
|
"fs-extra": "^11.0.0",
|
|
56
57
|
"got-scraping": "^4.2.1",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "67b3b3eb7d8d0716bfd458aa1a55c16fdb154858"
|
|
70
71
|
}
|