-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b06e0b8
commit 51a7bbe
Showing
6 changed files
with
350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 6 | ||
configured_endpoints: 9 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-73f12c3021fc56466b869b17a82fec982131d51e383151c897908d874bc188da.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
export interface PdfResponse { | ||
/** | ||
* URL where the PDF is hosted | ||
*/ | ||
url: string; | ||
} | ||
|
||
/** | ||
* Response from a successful scrape request | ||
*/ | ||
export interface ScrapeResponse { | ||
content: ScrapeResponse.Content; | ||
|
||
links: Array<ScrapeResponse.Link>; | ||
|
||
metadata: ScrapeResponse.Metadata; | ||
|
||
pdf?: ScrapeResponse.Pdf; | ||
|
||
screenshot?: ScrapeResponse.Screenshot; | ||
} | ||
|
||
export namespace ScrapeResponse { | ||
export interface Content { | ||
/** | ||
* Cleaned HTML content of the webpage | ||
*/ | ||
cleaned_html?: string; | ||
|
||
/** | ||
* Raw HTML content of the webpage | ||
*/ | ||
html?: string; | ||
|
||
/** | ||
* Webpage content converted to Markdown | ||
*/ | ||
markdown?: string; | ||
|
||
/** | ||
* Webpage content in Readability format | ||
*/ | ||
readability?: Record<string, unknown>; | ||
} | ||
|
||
export interface Link { | ||
/** | ||
* Text content of the link | ||
*/ | ||
text: string; | ||
|
||
/** | ||
* URL of the link | ||
*/ | ||
url: string; | ||
} | ||
|
||
export interface Metadata { | ||
/** | ||
* HTTP status code of the response | ||
*/ | ||
statusCode: number; | ||
|
||
/** | ||
* Description of the webpage | ||
*/ | ||
description?: string; | ||
|
||
/** | ||
* Detected language of the webpage | ||
*/ | ||
language?: string; | ||
|
||
/** | ||
* Open Graph description | ||
*/ | ||
ogDescription?: string; | ||
|
||
/** | ||
* Open Graph image URL | ||
*/ | ||
ogImage?: string; | ||
|
||
/** | ||
* Open Graph title | ||
*/ | ||
ogTitle?: string; | ||
|
||
/** | ||
* Publication timestamp of the content (if available) | ||
*/ | ||
published_timestamp?: string; | ||
|
||
/** | ||
* Timestamp when the scrape was performed | ||
*/ | ||
timestamp?: string; | ||
|
||
/** | ||
* Title of the webpage | ||
*/ | ||
title?: string; | ||
|
||
/** | ||
* Source URL of the scraped page | ||
*/ | ||
urlSource?: string; | ||
} | ||
|
||
export interface Pdf { | ||
/** | ||
* URL of the generated PDF | ||
*/ | ||
url: string; | ||
} | ||
|
||
export interface Screenshot { | ||
/** | ||
* URL of the screenshot image | ||
*/ | ||
url: string; | ||
} | ||
} | ||
|
||
export interface ScreenshotResponse { | ||
/** | ||
* URL where the screenshot is hosted | ||
*/ | ||
url: string; | ||
} | ||
|
||
export interface PdfParams { | ||
/** | ||
* URL of the webpage to convert to PDF | ||
*/ | ||
url: string; | ||
|
||
/** | ||
* Delay before generating the PDF (in milliseconds) | ||
*/ | ||
delay?: number; | ||
|
||
/** | ||
* Use a Steel-provided residential proxy for generating the PDF | ||
*/ | ||
useProxy?: boolean; | ||
} | ||
|
||
export interface ScrapeParams { | ||
/** | ||
* URL of the webpage to scrape | ||
*/ | ||
url: string; | ||
|
||
/** | ||
* Delay before scraping (in milliseconds) | ||
*/ | ||
delay?: number; | ||
|
||
/** | ||
* Desired format(s) for the scraped content. Default is `html`. | ||
*/ | ||
format?: Array<'html' | 'readability' | 'cleaned_html' | 'markdown'>; | ||
|
||
/** | ||
* Include a PDF in the response | ||
*/ | ||
pdf?: boolean; | ||
|
||
/** | ||
* Include a screenshot in the response | ||
*/ | ||
screenshot?: boolean; | ||
|
||
/** | ||
* Use a Steel-provided residential proxy for the scrape | ||
*/ | ||
useProxy?: boolean; | ||
} | ||
|
||
export interface ScreenshotParams { | ||
/** | ||
* URL of the webpage to capture | ||
*/ | ||
url: string; | ||
|
||
/** | ||
* Delay before capturing the screenshot (in milliseconds) | ||
*/ | ||
delay?: number; | ||
|
||
/** | ||
* Capture the full page screenshot. Default is `false`. | ||
*/ | ||
fullPage?: boolean; | ||
|
||
/** | ||
* Use a Steel-provided residential proxy for capturing the screenshot | ||
*/ | ||
useProxy?: boolean; | ||
} | ||
|
||
export declare namespace TopLevel { | ||
export { | ||
type PdfResponse as PdfResponse, | ||
type ScrapeResponse as ScrapeResponse, | ||
type ScreenshotResponse as ScreenshotResponse, | ||
type PdfParams as PdfParams, | ||
type ScrapeParams as ScrapeParams, | ||
type ScreenshotParams as ScreenshotParams, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import Steel from 'steel-sdk'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const client = new Steel({ | ||
steelAPIKey: 'My Steel API Key', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('top level methods', () => { | ||
test('pdf: only required params', async () => { | ||
const responsePromise = client.pdf({ url: 'https://example.com' }); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('pdf: required and optional params', async () => { | ||
const response = await client.pdf({ url: 'https://example.com', delay: 0, useProxy: true }); | ||
}); | ||
|
||
test('scrape: only required params', async () => { | ||
const responsePromise = client.scrape({ url: 'https://example.com' }); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('scrape: required and optional params', async () => { | ||
const response = await client.scrape({ | ||
url: 'https://example.com', | ||
delay: 0, | ||
format: ['html'], | ||
pdf: true, | ||
screenshot: true, | ||
useProxy: true, | ||
}); | ||
}); | ||
|
||
test('screenshot: only required params', async () => { | ||
const responsePromise = client.screenshot({ url: 'https://example.com' }); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('screenshot: required and optional params', async () => { | ||
const response = await client.screenshot({ | ||
url: 'https://example.com', | ||
delay: 0, | ||
fullPage: true, | ||
useProxy: true, | ||
}); | ||
}); | ||
}); |