@crawlee/basic 4.0.0-beta.236 → 4.0.0-beta.238
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.
- package/internals/basic-crawler.js +21 -13
- package/internals/crawler-run.js +2 -0
- package/package.json +7 -7
|
@@ -795,18 +795,6 @@ export class BasicCrawler {
|
|
|
795
795
|
if (this.running) {
|
|
796
796
|
throw new Error('This crawler instance is already running, you can add more requests to it via `crawler.addRequests()`.');
|
|
797
797
|
}
|
|
798
|
-
if (this.#hasFinishedBefore) {
|
|
799
|
-
// A supplied statistics instance keeps whatever state it was handed - only wipe a default we built.
|
|
800
|
-
await this.#statisticsDep.ifOwned(async (stats) => {
|
|
801
|
-
stats.reset();
|
|
802
|
-
await stats.resetStore();
|
|
803
|
-
});
|
|
804
|
-
// A session pool the crawler built follows the same blank-slate rule as its statistics.
|
|
805
|
-
await this.#sessionPoolDep.ifOwned(async (pool) => {
|
|
806
|
-
pool.reset();
|
|
807
|
-
await pool.resetStore();
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
798
|
// An owned governor is rebuilt for every run, so it always starts from a clean slate — stale
|
|
811
799
|
// resource snapshots or a previous run's scaled desired concurrency would otherwise distort this
|
|
812
800
|
// run's scaling. An injected one is long-lived and its lifecycle belongs to the caller.
|
|
@@ -819,6 +807,18 @@ export class BasicCrawler {
|
|
|
819
807
|
});
|
|
820
808
|
this.#run = run;
|
|
821
809
|
try {
|
|
810
|
+
if (this.#hasFinishedBefore) {
|
|
811
|
+
// A supplied statistics instance keeps whatever state it was handed - only wipe a default we built.
|
|
812
|
+
await this.#statisticsDep.ifOwned(async (stats) => {
|
|
813
|
+
stats.reset();
|
|
814
|
+
await stats.resetStore();
|
|
815
|
+
});
|
|
816
|
+
// A session pool the crawler built follows the same blank-slate rule as its statistics.
|
|
817
|
+
await this.#sessionPoolDep.ifOwned(async (pool) => {
|
|
818
|
+
pool.reset();
|
|
819
|
+
await pool.resetStore();
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
822
|
await purgeDefaultStorages({
|
|
823
823
|
onlyPurgeOnce: true,
|
|
824
824
|
storageBackend: serviceLocator.getStorageBackend(),
|
|
@@ -1455,7 +1455,15 @@ export class BasicCrawler {
|
|
|
1455
1455
|
if (cachedRobotsTxtFile) {
|
|
1456
1456
|
return cachedRobotsTxtFile;
|
|
1457
1457
|
}
|
|
1458
|
-
|
|
1458
|
+
// Fetch robots.txt the way pages are fetched: through the crawler's HTTP client, with a session's browser
|
|
1459
|
+
// fingerprint and proxy. Sites with bot protection answer a bare request with 4xx or 5xx, and that status
|
|
1460
|
+
// alone would then decide whether everything is allowed or disallowed.
|
|
1461
|
+
const robotsTxtFile = await RobotsTxtFile.find(url, {
|
|
1462
|
+
httpClient: this.httpClient,
|
|
1463
|
+
session: await this.sessionPool.getSession(),
|
|
1464
|
+
timeoutMillis: 30_000,
|
|
1465
|
+
logger: this.log,
|
|
1466
|
+
});
|
|
1459
1467
|
this.#robotsTxtFileCache.add(origin, robotsTxtFile);
|
|
1460
1468
|
return robotsTxtFile;
|
|
1461
1469
|
}
|
package/internals/crawler-run.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/basic",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.238",
|
|
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": ">=22.13.0"
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@apify/datastructures": "^3.0.1",
|
|
43
43
|
"@apify/timeout": "^1.0.1",
|
|
44
44
|
"@apify/utilities": "^3.0.1",
|
|
45
|
-
"@crawlee/core": "4.0.0-beta.
|
|
46
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
47
|
-
"@crawlee/types": "4.0.0-beta.
|
|
48
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
45
|
+
"@crawlee/core": "4.0.0-beta.238",
|
|
46
|
+
"@crawlee/http-client": "4.0.0-beta.238",
|
|
47
|
+
"@crawlee/types": "4.0.0-beta.238",
|
|
48
|
+
"@crawlee/utils": "4.0.0-beta.238",
|
|
49
49
|
"@sapphire/async-queue": "^1.5.5",
|
|
50
50
|
"@standard-schema/spec": "^1.0.0",
|
|
51
51
|
"csv-stringify": "^6.5.2",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"zod": "^4.5.4"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"@crawlee/impit-client": "4.0.0-beta.
|
|
60
|
+
"@crawlee/impit-client": "4.0.0-beta.238"
|
|
61
61
|
},
|
|
62
62
|
"lerna": {
|
|
63
63
|
"command": {
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "8c6b2f3b5a811ca68672b6c68b6587a925baf2aa"
|
|
70
70
|
}
|