@crawlee/http 3.17.1-beta.7 → 3.17.1-beta.71
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/index.mjs
CHANGED
|
@@ -52,6 +52,7 @@ export const RequestQueue = mod.RequestQueue;
|
|
|
52
52
|
export const RequestQueueV1 = mod.RequestQueueV1;
|
|
53
53
|
export const RequestQueueV2 = mod.RequestQueueV2;
|
|
54
54
|
export const RequestState = mod.RequestState;
|
|
55
|
+
export const RequestValidationError = mod.RequestValidationError;
|
|
55
56
|
export const RetryRequestError = mod.RetryRequestError;
|
|
56
57
|
export const Router = mod.Router;
|
|
57
58
|
export const STATE_PERSISTENCE_KEY = mod.STATE_PERSISTENCE_KEY;
|
|
@@ -82,6 +83,7 @@ export const createFileRouter = mod.createFileRouter;
|
|
|
82
83
|
export const createHttpRouter = mod.createHttpRouter;
|
|
83
84
|
export const createRequestOptions = mod.createRequestOptions;
|
|
84
85
|
export const createRequests = mod.createRequests;
|
|
86
|
+
export const defaultRoute = mod.defaultRoute;
|
|
85
87
|
export const deserializeArray = mod.deserializeArray;
|
|
86
88
|
export const enqueueLinks = mod.enqueueLinks;
|
|
87
89
|
export const evaluateLoadSignalSample = mod.evaluateLoadSignalSample;
|
|
@@ -102,5 +104,6 @@ export const tryAbsoluteURL = mod.tryAbsoluteURL;
|
|
|
102
104
|
export const updateEnqueueLinksPatternCache = mod.updateEnqueueLinksPatternCache;
|
|
103
105
|
export const useState = mod.useState;
|
|
104
106
|
export const validateGlobPattern = mod.validateGlobPattern;
|
|
107
|
+
export const validateUserData = mod.validateUserData;
|
|
105
108
|
export const validators = mod.validators;
|
|
106
109
|
export const withCheckedStorageAccess = mod.withCheckedStorageAccess;
|
|
@@ -2,7 +2,7 @@ import { Transform } from 'node:stream';
|
|
|
2
2
|
import type { Dictionary } from '@crawlee/types';
|
|
3
3
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
4
4
|
import type { Request } from 'got-scraping';
|
|
5
|
-
import type { ErrorHandler, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterRoutes } from '../index';
|
|
5
|
+
import type { ErrorHandler, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '../index';
|
|
6
6
|
import { HttpCrawler } from '../index';
|
|
7
7
|
export type FileDownloadErrorHandler<UserData extends Dictionary = any, // with default to Dictionary we cant use a typed router in untyped crawler
|
|
8
8
|
JSONData extends Dictionary = any> = ErrorHandler<FileDownloadCrawlingContext<UserData, JSONData>>;
|
|
@@ -124,6 +124,7 @@ export declare class FileDownload extends HttpCrawler<FileDownloadCrawlingContex
|
|
|
124
124
|
* await crawler.run();
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
|
-
|
|
128
|
-
export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData
|
|
127
|
+
export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
|
|
128
|
+
export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
|
|
129
|
+
export declare function createFileRouter<Context extends FileDownloadCrawlingContext = FileDownloadCrawlingContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
|
|
129
130
|
export {};
|
|
@@ -209,30 +209,6 @@ class FileDownload extends index_1.HttpCrawler {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.FileDownload = FileDownload;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
* This instance can then serve as a `requestHandler` of your {@link FileDownload}.
|
|
215
|
-
* Defaults to the {@link FileDownloadCrawlingContext}.
|
|
216
|
-
*
|
|
217
|
-
* > Serves as a shortcut for using `Router.create<FileDownloadCrawlingContext>()`.
|
|
218
|
-
*
|
|
219
|
-
* ```ts
|
|
220
|
-
* import { FileDownload, createFileRouter } from 'crawlee';
|
|
221
|
-
*
|
|
222
|
-
* const router = createFileRouter();
|
|
223
|
-
* router.addHandler('label-a', async (ctx) => {
|
|
224
|
-
* ctx.log.info('...');
|
|
225
|
-
* });
|
|
226
|
-
* router.addDefaultHandler(async (ctx) => {
|
|
227
|
-
* ctx.log.info('...');
|
|
228
|
-
* });
|
|
229
|
-
*
|
|
230
|
-
* const crawler = new FileDownload({
|
|
231
|
-
* requestHandler: router,
|
|
232
|
-
* });
|
|
233
|
-
* await crawler.run();
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
function createFileRouter(routes) {
|
|
237
|
-
return index_1.Router.create(routes);
|
|
212
|
+
function createFileRouter(routesOrSchemas) {
|
|
213
|
+
return index_1.Router.create(routesOrSchemas);
|
|
238
214
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'node:http';
|
|
2
2
|
import type { Readable } from 'node:stream';
|
|
3
|
-
import type { BasicCrawlerOptions, CrawlingContext, ErrorHandler, GetUserDataFromRequest, ProxyConfiguration, Request, RequestHandler, RouterRoutes, Session } from '@crawlee/basic';
|
|
3
|
+
import type { BasicCrawlerOptions, CrawlingContext, ErrorHandler, GetUserDataFromRequest, ProxyConfiguration, Request, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas, Session } from '@crawlee/basic';
|
|
4
4
|
import { BasicCrawler, Configuration, CrawlerExtension } from '@crawlee/basic';
|
|
5
5
|
import type { HttpResponse } from '@crawlee/core';
|
|
6
6
|
import type { Awaitable, Dictionary } from '@crawlee/types';
|
|
@@ -426,7 +426,7 @@ export declare class HttpCrawler<Context extends InternalHttpCrawlingContext<any
|
|
|
426
426
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
427
427
|
searchParams?: string | import("got-scraping", { with: { "resolution-mode": "import" } }).SearchParameters | URLSearchParams | undefined;
|
|
428
428
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
429
|
-
dnsLookup?: import("
|
|
429
|
+
dnsLookup?: import("net").LookupFunction | undefined;
|
|
430
430
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
431
431
|
dnsCache?: import("cacheable-lookup", { with: { "resolution-mode": "import" } }).default | boolean | undefined;
|
|
432
432
|
context?: Record<string, unknown> | undefined;
|
|
@@ -525,6 +525,7 @@ interface RequestFunctionOptions {
|
|
|
525
525
|
* await crawler.run();
|
|
526
526
|
* ```
|
|
527
527
|
*/
|
|
528
|
-
|
|
529
|
-
export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData
|
|
528
|
+
export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
|
|
529
|
+
export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
|
|
530
|
+
export declare function createHttpRouter<Context extends HttpCrawlingContext = HttpCrawlingContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
|
|
530
531
|
export {};
|
|
@@ -709,30 +709,6 @@ function parseContentTypeFromResponse(response) {
|
|
|
709
709
|
charset: parsedContentType.parameters.charset,
|
|
710
710
|
};
|
|
711
711
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
* This instance can then serve as a `requestHandler` of your {@link HttpCrawler}.
|
|
715
|
-
* Defaults to the {@link HttpCrawlingContext}.
|
|
716
|
-
*
|
|
717
|
-
* > Serves as a shortcut for using `Router.create<HttpCrawlingContext>()`.
|
|
718
|
-
*
|
|
719
|
-
* ```ts
|
|
720
|
-
* import { HttpCrawler, createHttpRouter } from 'crawlee';
|
|
721
|
-
*
|
|
722
|
-
* const router = createHttpRouter();
|
|
723
|
-
* router.addHandler('label-a', async (ctx) => {
|
|
724
|
-
* ctx.log.info('...');
|
|
725
|
-
* });
|
|
726
|
-
* router.addDefaultHandler(async (ctx) => {
|
|
727
|
-
* ctx.log.info('...');
|
|
728
|
-
* });
|
|
729
|
-
*
|
|
730
|
-
* const crawler = new HttpCrawler({
|
|
731
|
-
* requestHandler: router,
|
|
732
|
-
* });
|
|
733
|
-
* await crawler.run();
|
|
734
|
-
* ```
|
|
735
|
-
*/
|
|
736
|
-
function createHttpRouter(routes) {
|
|
737
|
-
return basic_1.Router.create(routes);
|
|
712
|
+
function createHttpRouter(routesOrSchemas) {
|
|
713
|
+
return basic_1.Router.create(routesOrSchemas);
|
|
738
714
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/http",
|
|
3
|
-
"version": "3.17.1-beta.
|
|
3
|
+
"version": "3.17.1-beta.71",
|
|
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"
|
|
@@ -53,11 +53,12 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@apify/timeout": "^0.
|
|
56
|
+
"@apify/timeout": "^0.4.0",
|
|
57
57
|
"@apify/utilities": "^2.7.10",
|
|
58
|
-
"@crawlee/basic": "3.17.1-beta.
|
|
59
|
-
"@crawlee/
|
|
60
|
-
"@crawlee/
|
|
58
|
+
"@crawlee/basic": "3.17.1-beta.71",
|
|
59
|
+
"@crawlee/core": "3.17.1-beta.71",
|
|
60
|
+
"@crawlee/types": "3.17.1-beta.71",
|
|
61
|
+
"@crawlee/utils": "3.17.1-beta.71",
|
|
61
62
|
"@types/content-type": "^1.1.5",
|
|
62
63
|
"cheerio": "1.0.0-rc.12",
|
|
63
64
|
"content-type": "^1.0.4",
|
|
@@ -75,5 +76,5 @@
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
},
|
|
78
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "94c4c029140e4068184ad3f03d0a71fd8d6984dc"
|
|
79
80
|
}
|