webcrawlerapi-js 2.0.7 → 2.0.10
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/README.md +3 -3
- package/dist/@types/api.d.ts +3 -2
- package/dist/@types/model.d.ts +6 -0
- package/dist/api.js +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ In this mode, the promise will be resolved when all data is ready. Synchronous j
|
|
|
27
27
|
import webcrawlerapi from "webcrawlerapi-js"
|
|
28
28
|
|
|
29
29
|
async function main() {
|
|
30
|
-
const client = new WebcrawlerClient("YOUR API ACCESS KEY HERE")
|
|
30
|
+
const client = new webcrawlerapi.WebcrawlerClient("YOUR API ACCESS KEY HERE")
|
|
31
31
|
|
|
32
32
|
try {
|
|
33
33
|
const crawlJob = await client.crawl({
|
|
@@ -64,7 +64,7 @@ In this mode, you get a job ID immediately and can poll for results. Asynchronou
|
|
|
64
64
|
import webcrawlerapi from "webcrawlerapi-js"
|
|
65
65
|
|
|
66
66
|
async function main() {
|
|
67
|
-
const client = new WebcrawlerClient("YOUR API ACCESS KEY HERE")
|
|
67
|
+
const client = new webcrawlerapi.WebcrawlerClient("YOUR API ACCESS KEY HERE")
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
70
|
try {
|
|
@@ -115,7 +115,7 @@ The SDK provides full TypeScript support with type safety and error handling. Ou
|
|
|
115
115
|
import {WebcrawlerClient, WebcrawlerApiError} from "webcrawlerapi-js";
|
|
116
116
|
|
|
117
117
|
async function main() {
|
|
118
|
-
const client = new WebcrawlerClient("YOUR_API_KEY")
|
|
118
|
+
const client = new webcrawlerapi.WebcrawlerClient("YOUR_API_KEY")
|
|
119
119
|
|
|
120
120
|
try {
|
|
121
121
|
// Basic crawl with markdown
|
package/dist/@types/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, Action } from "./model";
|
|
1
|
+
import { CrawlRequest, Job, JobId, ScrapeRequest, ScrapeResponse, ScrapeResponseError, ScrapeId, Action, JobMarkdownResponse } from "./model";
|
|
2
2
|
import { JobStatus, ErrorCode } from "./constants";
|
|
3
3
|
import { WebcrawlerApiError } from "./errors";
|
|
4
4
|
export { WebcrawlerApiError, JobStatus, ErrorCode };
|
|
@@ -15,6 +15,7 @@ export declare class WebcrawlerClient {
|
|
|
15
15
|
crawl(crawlRequest: CrawlRequest, actions?: Action | Action[]): Promise<Job>;
|
|
16
16
|
crawlAsync(crawlRequest: CrawlRequest, actions?: Action | Action[]): Promise<JobId>;
|
|
17
17
|
getJob(jobID: string): Promise<Job>;
|
|
18
|
-
getJobMarkdown(jobID: string): Promise<
|
|
18
|
+
getJobMarkdown(jobID: string): Promise<JobMarkdownResponse>;
|
|
19
|
+
getJobMarkdownContent(jobID: string): Promise<string>;
|
|
19
20
|
private sendRequest;
|
|
20
21
|
}
|
package/dist/@types/model.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface ScrapeRequest {
|
|
|
5
5
|
clean_selectors?: string;
|
|
6
6
|
actions?: Action[];
|
|
7
7
|
prompt?: string;
|
|
8
|
+
response_schema?: Record<string, any>;
|
|
8
9
|
respect_robots_txt?: boolean;
|
|
9
10
|
main_content_only?: boolean;
|
|
10
11
|
max_age?: number;
|
|
@@ -21,6 +22,7 @@ export interface ScrapeResponse {
|
|
|
21
22
|
page_status_code: number;
|
|
22
23
|
page_title?: string;
|
|
23
24
|
structured_data?: any;
|
|
25
|
+
links?: string[];
|
|
24
26
|
}
|
|
25
27
|
export interface ScrapeResponseError {
|
|
26
28
|
success: boolean;
|
|
@@ -78,6 +80,7 @@ export interface JobItem {
|
|
|
78
80
|
depth?: number;
|
|
79
81
|
raw_content_url?: string;
|
|
80
82
|
cleaned_content_url?: string;
|
|
83
|
+
error_code?: string;
|
|
81
84
|
getContent(): Promise<string | null>;
|
|
82
85
|
}
|
|
83
86
|
export interface Action {
|
|
@@ -91,3 +94,6 @@ export interface UploadS3Action extends Action {
|
|
|
91
94
|
bucket: string;
|
|
92
95
|
endpoint?: string;
|
|
93
96
|
}
|
|
97
|
+
export interface JobMarkdownResponse {
|
|
98
|
+
content_url: string;
|
|
99
|
+
}
|
package/dist/api.js
CHANGED
|
@@ -150,7 +150,7 @@ class WebcrawlerClient {
|
|
|
150
150
|
if (job.scrape_type !== 'markdown') {
|
|
151
151
|
throw new errors_1.WebcrawlerApiError('invalid_scrape_type', 'CrawlRawMarkdown requires scrape_type to be markdown', 0);
|
|
152
152
|
}
|
|
153
|
-
return this.
|
|
153
|
+
return this.getJobMarkdownContent(job.id);
|
|
154
154
|
}
|
|
155
155
|
async crawl(crawlRequest, actions) {
|
|
156
156
|
const url = `${this.basePath}/${this.apiVersion}/crawl`;
|
|
@@ -233,6 +233,21 @@ class WebcrawlerClient {
|
|
|
233
233
|
'Expires': '0'
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
|
+
return this.sendRequest(url, requestOptions);
|
|
237
|
+
}
|
|
238
|
+
async getJobMarkdownContent(jobID) {
|
|
239
|
+
const url = `${this.basePath}/${this.apiVersion}/job/${jobID}/markdown/content`;
|
|
240
|
+
const requestOptions = {
|
|
241
|
+
'method': 'GET',
|
|
242
|
+
'headers': {
|
|
243
|
+
'Content-Type': 'application/json',
|
|
244
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
245
|
+
"User-Agent": "WebcrawlerAPI-NodeJS-Client",
|
|
246
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
247
|
+
'Pragma': 'no-cache',
|
|
248
|
+
'Expires': '0'
|
|
249
|
+
}
|
|
250
|
+
};
|
|
236
251
|
let response;
|
|
237
252
|
try {
|
|
238
253
|
response = await fetch(url, requestOptions);
|