Skip to content

Commit 854f338

Browse files
committed
add js examples
1 parent cf5a26d commit 854f338

File tree

10 files changed

+1311
-1168
lines changed

10 files changed

+1311
-1168
lines changed

scrapegraph-js/README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ const prompt = 'What does the company do?';
5555

5656
## 🎯 Examples
5757

58-
### HTMLfy - Get HTML Content
58+
### Scrape - Get HTML Content
5959

60-
#### Basic HTMLfy
60+
#### Basic Scrape
6161

6262
```javascript
63-
import { htmlfy } from 'scrapegraph-js';
63+
import { scrape } from 'scrapegraph-js';
6464

6565
const apiKey = 'your-api-key';
6666
const url = 'https://example.com';
6767

6868
(async () => {
6969
try {
70-
const response = await htmlfy(apiKey, url);
70+
const response = await scrape(apiKey, url);
7171
console.log('HTML content:', response.html);
7272
console.log('Status:', response.status);
7373
} catch (error) {
@@ -76,17 +76,17 @@ const url = 'https://example.com';
7676
})();
7777
```
7878

79-
#### HTMLfy with Heavy JavaScript Rendering
79+
#### Scrape with Heavy JavaScript Rendering
8080

8181
```javascript
82-
import { htmlfy } from 'scrapegraph-js';
82+
import { scrape } from 'scrapegraph-js';
8383

8484
const apiKey = 'your-api-key';
8585
const url = 'https://example.com';
8686

8787
(async () => {
8888
try {
89-
const response = await htmlfy(apiKey, url, {
89+
const response = await scrape(apiKey, url, {
9090
renderHeavyJs: true
9191
});
9292
console.log('HTML content with JS rendering:', response.html);
@@ -96,17 +96,17 @@ const url = 'https://example.com';
9696
})();
9797
```
9898

99-
#### HTMLfy with Custom Headers
99+
#### Scrape with Custom Headers
100100

101101
```javascript
102-
import { htmlfy } from 'scrapegraph-js';
102+
import { scrape } from 'scrapegraph-js';
103103

104104
const apiKey = 'your-api-key';
105105
const url = 'https://example.com';
106106

107107
(async () => {
108108
try {
109-
const response = await htmlfy(apiKey, url, {
109+
const response = await scrape(apiKey, url, {
110110
headers: {
111111
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
112112
'Cookie': 'session=123'
@@ -119,17 +119,17 @@ const url = 'https://example.com';
119119
})();
120120
```
121121

122-
#### Get HTMLfy Request Status
122+
#### Get Scrape Request Status
123123

124124
```javascript
125-
import { getHtmlfyRequest } from 'scrapegraph-js';
125+
import { getScrapeRequest } from 'scrapegraph-js';
126126

127127
const apiKey = 'your-api-key';
128128
const requestId = 'your-request-id';
129129

130130
(async () => {
131131
try {
132-
const response = await getHtmlfyRequest(apiKey, requestId);
132+
const response = await getScrapeRequest(apiKey, requestId);
133133
console.log('Request status:', response.status);
134134
if (response.status === 'completed') {
135135
console.log('HTML content:', response.html);
@@ -482,9 +482,9 @@ const feedbackText = 'This is a test feedback message.';
482482

483483
## 🔧 Available Functions
484484

485-
### HTMLfy
485+
### Scrape
486486

487-
#### `htmlfy(apiKey, url, options)`
487+
#### `scrape(apiKey, url, options)`
488488

489489
Converts a webpage into HTML format with optional JavaScript rendering.
490490

@@ -498,30 +498,30 @@ Converts a webpage into HTML format with optional JavaScript rendering.
498498
**Returns:** Promise that resolves to an object containing:
499499
- `html`: The HTML content of the webpage
500500
- `status`: Request status ('completed', 'processing', 'failed')
501-
- `htmlfy_request_id`: Unique identifier for the request
501+
- `scrape_request_id`: Unique identifier for the request
502502
- `error`: Error message if the request failed
503503

504504
**Example:**
505505
```javascript
506-
const response = await htmlfy(apiKey, 'https://example.com', {
506+
const response = await scrape(apiKey, 'https://example.com', {
507507
renderHeavyJs: true,
508508
headers: { 'User-Agent': 'Custom Agent' }
509509
});
510510
```
511511

512-
#### `getHtmlfyRequest(apiKey, requestId)`
512+
#### `getScrapeRequest(apiKey, requestId)`
513513

514-
Retrieves the status or result of a previous HTMLfy request.
514+
Retrieves the status or result of a previous scrape request.
515515

516516
**Parameters:**
517517
- `apiKey` (string): Your ScrapeGraph AI API key
518-
- `requestId` (string): The unique identifier for the HTMLfy request
518+
- `requestId` (string): The unique identifier for the scrape request
519519

520520
**Returns:** Promise that resolves to the request result object.
521521

522522
**Example:**
523523
```javascript
524-
const result = await getHtmlfyRequest(apiKey, 'request-id-here');
524+
const result = await getScrapeRequest(apiKey, 'request-id-here');
525525
```
526526

527527
### Smart Scraper

0 commit comments

Comments
 (0)