feat: add userAgent parameter for custom User-Agent headers
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
- Add userAgent?: string to ScreenshotOptions interface - Implement validation (max 500 chars, no newlines for security) - Call page.setUserAgent() after page acquisition, before navigation - Add route handler support for both POST body and GET query - Add comprehensive test coverage (11 new tests) - Update OpenAPI documentation with parameter specs and examples - Update Node.js and Python SDK README examples - All userAgent tests passing (414 → 425 total tests) Fixes potential HTTP header injection by rejecting newlines. Enables custom User-Agent strings for specific browser emulation needs.
This commit is contained in:
parent
a17f492cc3
commit
9290c759da
5 changed files with 313 additions and 0 deletions
|
|
@ -83,6 +83,17 @@ const darkScreenshot = await snap.capture({
|
|||
});
|
||||
```
|
||||
|
||||
### Custom User Agent
|
||||
|
||||
```typescript
|
||||
// Set a custom User-Agent string for the request
|
||||
const screenshot = await snap.capture({
|
||||
url: 'https://example.com',
|
||||
userAgent: 'Mozilla/5.0 (compatible; SnapAPI/1.0)',
|
||||
format: 'png',
|
||||
});
|
||||
```
|
||||
|
||||
### Hide Elements Before Capture
|
||||
|
||||
```typescript
|
||||
|
|
|
|||
|
|
@ -86,6 +86,17 @@ dark_screenshot = snap.capture(
|
|||
)
|
||||
```
|
||||
|
||||
### Custom User Agent
|
||||
|
||||
```python
|
||||
# Set a custom User-Agent string for the request
|
||||
screenshot = snap.capture(
|
||||
"https://example.com",
|
||||
user_agent="Mozilla/5.0 (compatible; SnapAPI/1.0)",
|
||||
format="png",
|
||||
)
|
||||
```
|
||||
|
||||
### Hide Elements Before Capture
|
||||
|
||||
```python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue