webcrawlerapi-js 2.0.9 → 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/dist/@types/api.d.ts +3 -2
- package/dist/@types/model.d.ts +3 -0
- package/dist/api.js +16 -1
- package/package.json +1 -1
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
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);
|