@hyperbrowser/sdk 0.4.0 → 0.6.0
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/dist/client.d.ts +3 -0
- package/dist/client.js +27 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/crawl.d.ts +43 -0
- package/dist/types/crawl.js +2 -0
- package/dist/types/scrape.d.ts +2 -0
- package/dist/types/session.d.ts +8 -4
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Response } from "node-fetch";
|
|
|
2
2
|
import { HyperbrowserConfig } from "./types/config";
|
|
3
3
|
import { BasicResponse, CreateSessionParams, SessionDetail, SessionListParams, SessionListResponse } from "./types/session";
|
|
4
4
|
import { ScrapeJobResponse, StartScrapeJobParams, StartScrapeJobResponse } from "./types/scrape";
|
|
5
|
+
import { CrawlJobResponse, GetCrawlJobParams, StartCrawlJobParams, StartCrawlJobResponse } from "./types/crawl";
|
|
5
6
|
export declare class HyperbrowserError extends Error {
|
|
6
7
|
statusCode?: number | undefined;
|
|
7
8
|
response?: Response | undefined;
|
|
@@ -32,4 +33,6 @@ export declare class HyperbrowserClient {
|
|
|
32
33
|
listSessions(params?: SessionListParams): Promise<SessionListResponse>;
|
|
33
34
|
startScrapeJob(params: StartScrapeJobParams): Promise<StartScrapeJobResponse>;
|
|
34
35
|
getScrapeJob(id: string): Promise<ScrapeJobResponse>;
|
|
36
|
+
startCrawlJob(params: StartCrawlJobParams): Promise<StartCrawlJobResponse>;
|
|
37
|
+
getCrawlJob(id: string, params?: GetCrawlJobParams): Promise<CrawlJobResponse>;
|
|
35
38
|
}
|
package/dist/client.js
CHANGED
|
@@ -162,5 +162,32 @@ class HyperbrowserClient {
|
|
|
162
162
|
throw new HyperbrowserError(`Failed to get scrape job ${id}`, undefined, undefined, error instanceof Error ? error : undefined);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
+
async startCrawlJob(params) {
|
|
166
|
+
try {
|
|
167
|
+
return await this.request("/crawl", {
|
|
168
|
+
method: "POST",
|
|
169
|
+
body: JSON.stringify(params),
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (error instanceof HyperbrowserError) {
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
throw new HyperbrowserError("Failed to start crawl job", undefined, undefined, error instanceof Error ? error : undefined);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async getCrawlJob(id, params) {
|
|
180
|
+
try {
|
|
181
|
+
return await this.request(`/crawl/${id}`, undefined, {
|
|
182
|
+
page: params?.page,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
if (error instanceof HyperbrowserError) {
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
throw new HyperbrowserError(`Failed to get crawl job ${id}`, undefined, undefined, error instanceof Error ? error : undefined);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
165
192
|
}
|
|
166
193
|
exports.HyperbrowserClient = HyperbrowserClient;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type ScrapeJobStatus = "pending" | "running" | "completed" | "failed";
|
|
2
|
+
export type CrawlJobStatus = "pending" | "running" | "completed" | "failed";
|
|
2
3
|
export type Country = "AD" | "AE" | "AF" | "AL" | "AM" | "AO" | "AR" | "AT" | "AU" | "AW" | "AZ" | "BA" | "BD" | "BE" | "BG" | "BH" | "BJ" | "BO" | "BR" | "BS" | "BT" | "BY" | "BZ" | "CA" | "CF" | "CH" | "CI" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "EC" | "EE" | "EG" | "ES" | "ET" | "EU" | "FI" | "FJ" | "FR" | "GB" | "GE" | "GH" | "GM" | "GR" | "HK" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IN" | "IQ" | "IR" | "IS" | "IT" | "JM" | "JO" | "JP" | "KE" | "KH" | "KR" | "KW" | "KZ" | "LB" | "LI" | "LR" | "LT" | "LU" | "LV" | "MA" | "MC" | "MD" | "ME" | "MG" | "MK" | "ML" | "MM" | "MN" | "MR" | "MT" | "MU" | "MV" | "MX" | "MY" | "MZ" | "NG" | "NL" | "NO" | "NZ" | "OM" | "PA" | "PE" | "PH" | "PK" | "PL" | "PR" | "PT" | "PY" | "QA" | "RANDOM_COUNTRY" | "RO" | "RS" | "RU" | "SA" | "SC" | "SD" | "SE" | "SG" | "SI" | "SK" | "SN" | "SS" | "TD" | "TG" | "TH" | "TM" | "TN" | "TR" | "TT" | "TW" | "UA" | "UG" | "US" | "UY" | "UZ" | "VE" | "VG" | "VN" | "YE" | "ZA" | "ZM" | "ZW" | "ad" | "ae" | "af" | "al" | "am" | "ao" | "ar" | "at" | "au" | "aw" | "az" | "ba" | "bd" | "be" | "bg" | "bh" | "bj" | "bo" | "br" | "bs" | "bt" | "by" | "bz" | "ca" | "cf" | "ch" | "ci" | "cl" | "cm" | "cn" | "co" | "cr" | "cu" | "cy" | "cz" | "de" | "dj" | "dk" | "dm" | "ec" | "ee" | "eg" | "es" | "et" | "eu" | "fi" | "fj" | "fr" | "gb" | "ge" | "gh" | "gm" | "gr" | "hk" | "hn" | "hr" | "ht" | "hu" | "id" | "ie" | "il" | "in" | "iq" | "ir" | "is" | "it" | "jm" | "jo" | "jp" | "ke" | "kh" | "kr" | "kw" | "kz" | "lb" | "li" | "lr" | "lt" | "lu" | "lv" | "ma" | "mc" | "md" | "me" | "mg" | "mk" | "ml" | "mm" | "mn" | "mr" | "mt" | "mu" | "mv" | "mx" | "my" | "mz" | "ng" | "nl" | "no" | "nz" | "om" | "pa" | "pe" | "ph" | "pk" | "pl" | "pr" | "pt" | "py" | "qa" | "ro" | "rs" | "ru" | "sa" | "sc" | "sd" | "se" | "sg" | "si" | "sk" | "sn" | "ss" | "td" | "tg" | "th" | "tm" | "tn" | "tr" | "tt" | "tw" | "ua" | "ug" | "us" | "uy" | "uz" | "ve" | "vg" | "vn" | "ye" | "za" | "zm" | "zw";
|
|
3
4
|
export type OperatingSystem = "windows" | "android" | "macos" | "linux" | "ios";
|
|
4
5
|
export type Platform = "chrome" | "firefox" | "safari" | "edge";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CrawlJobStatus } from "./constants";
|
|
2
|
+
export interface StartCrawlJobParams {
|
|
3
|
+
url: string;
|
|
4
|
+
maxPages: number;
|
|
5
|
+
followLinks: boolean;
|
|
6
|
+
excludePatterns: string[];
|
|
7
|
+
includePatterns: string[];
|
|
8
|
+
useProxy: boolean;
|
|
9
|
+
solveCaptchas: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface StartCrawlJobResponse {
|
|
12
|
+
jobId: string;
|
|
13
|
+
}
|
|
14
|
+
export interface GetCrawlJobParams {
|
|
15
|
+
page?: number;
|
|
16
|
+
batchSize?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface CrawledPageMetadata {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
robots: string;
|
|
22
|
+
ogTitle: string;
|
|
23
|
+
ogDescription: string;
|
|
24
|
+
ogUrl: string;
|
|
25
|
+
ogImage: string;
|
|
26
|
+
ogLocaleAlternate: string[];
|
|
27
|
+
ogSiteName: string;
|
|
28
|
+
sourceURL: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CrawledPage {
|
|
31
|
+
url: string;
|
|
32
|
+
metadata: CrawledPageMetadata;
|
|
33
|
+
markdown: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CrawlJobResponse {
|
|
36
|
+
status: CrawlJobStatus;
|
|
37
|
+
data?: CrawledPage[];
|
|
38
|
+
error?: string;
|
|
39
|
+
totalCrawledPages: number;
|
|
40
|
+
totalPageBatches: number;
|
|
41
|
+
currentPageBatch: number;
|
|
42
|
+
batchSize: number;
|
|
43
|
+
}
|
package/dist/types/scrape.d.ts
CHANGED
package/dist/types/session.d.ts
CHANGED
|
@@ -27,12 +27,12 @@ export interface SessionListResponse {
|
|
|
27
27
|
perPage: number;
|
|
28
28
|
}
|
|
29
29
|
export interface ScreenConfig {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
minWidth: number;
|
|
33
|
-
minHeight: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
34
32
|
}
|
|
35
33
|
export interface CreateSessionParams {
|
|
34
|
+
useStealth?: boolean;
|
|
35
|
+
useProxy?: boolean;
|
|
36
36
|
proxyServer?: string;
|
|
37
37
|
proxyServerPassword?: string;
|
|
38
38
|
proxyServerUsername?: string;
|
|
@@ -42,4 +42,8 @@ export interface CreateSessionParams {
|
|
|
42
42
|
platform?: Platform[];
|
|
43
43
|
locales?: ISO639_1[];
|
|
44
44
|
screen?: ScreenConfig;
|
|
45
|
+
solveCaptchas?: boolean;
|
|
46
|
+
adblock?: boolean;
|
|
47
|
+
trackers?: boolean;
|
|
48
|
+
annoyances?: boolean;
|
|
45
49
|
}
|