@crawlee/http 3.17.1-beta.4 → 3.17.1-beta.41
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.
|
@@ -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 } 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,6 @@ 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
129
|
export {};
|
|
@@ -209,30 +209,6 @@ class FileDownload extends index_1.HttpCrawler {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
exports.FileDownload = FileDownload;
|
|
212
|
-
/**
|
|
213
|
-
* Creates new {@link Router} instance that works based on request labels.
|
|
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
212
|
function createFileRouter(routes) {
|
|
237
213
|
return index_1.Router.create(routes);
|
|
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, 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,6 @@ 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
530
|
export {};
|
|
@@ -709,30 +709,6 @@ function parseContentTypeFromResponse(response) {
|
|
|
709
709
|
charset: parsedContentType.parameters.charset,
|
|
710
710
|
};
|
|
711
711
|
}
|
|
712
|
-
/**
|
|
713
|
-
* Creates new {@link Router} instance that works based on request labels.
|
|
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
712
|
function createHttpRouter(routes) {
|
|
737
713
|
return basic_1.Router.create(routes);
|
|
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.41",
|
|
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"
|
|
@@ -55,9 +55,10 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@apify/timeout": "^0.3.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.41",
|
|
59
|
+
"@crawlee/core": "3.17.1-beta.41",
|
|
60
|
+
"@crawlee/types": "3.17.1-beta.41",
|
|
61
|
+
"@crawlee/utils": "3.17.1-beta.41",
|
|
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": "6c01783829190e9904fc1288ac62844e552414e6"
|
|
79
80
|
}
|