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.
@@ -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<string>;
18
+ getJobMarkdown(jobID: string): Promise<JobMarkdownResponse>;
19
+ getJobMarkdownContent(jobID: string): Promise<string>;
19
20
  private sendRequest;
20
21
  }
@@ -94,3 +94,6 @@ export interface UploadS3Action extends Action {
94
94
  bucket: string;
95
95
  endpoint?: string;
96
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.getJobMarkdown(job.id);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcrawlerapi-js",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "JS client for WebcrawlerAPI",
5
5
  "main": "./dist/api.js",
6
6
  "types": "./dist/@types/api.d.ts",