1
1
# 🌐 ScrapeGraph JavaScript SDK
2
2
3
3
[ ![ npm version] ( https://badge.fury.io/js/scrapegraph-js.svg )] ( https://badge.fury.io/js/scrapegraph-js )
4
- [ ![ TypeScript Support] ( https://img.shields.io/badge/TypeScript-Ready-blue.svg )] ( https://www.typescriptlang.org/ )
5
4
[ ![ License] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://opensource.org/licenses/MIT )
6
5
[ ![ Build Status] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/actions/workflows/ci.yml/badge.svg )] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/actions )
7
6
[ ![ Documentation Status] ( https://img.shields.io/badge/docs-latest-brightgreen.svg )] ( https://docs.scrapegraphai.com )
@@ -11,8 +10,7 @@ Official JavaScript/TypeScript SDK for the ScrapeGraph AI API - Smart web scrapi
11
10
## 🚀 Features
12
11
13
12
- ✨ Smart web scraping with AI
14
- - 🔄 Fully asynchronous design
15
- - 📊 TypeScript-ready with strongly typed responses
13
+ - 🔄 Fully asynchronous design
16
14
- 🔍 Detailed error handling
17
15
- ⚡ Automatic retries and logging
18
16
- 🔐 Secure API authentication
@@ -23,7 +21,11 @@ Install the package using npm or yarn:
23
21
24
22
``` bash
25
23
# Using npm
26
- npm install scrapegraph-js
24
+ npm i scrapegraph-js
25
+
26
+ # Using yarn
27
+ yarn add scrapegraph-js
28
+ ```
27
29
28
30
29
31
## 🔧 Quick Start
@@ -34,6 +36,7 @@ npm install scrapegraph-js
34
36
35
37
``` javascript
36
38
import { smartScraper } from ' scrapegraph-js' ;
39
+ import ' dotenv/config' ;
37
40
38
41
// Initialize variables
39
42
const apiKey = process .env .SGAI_APIKEY ; // Set your API key as an environment variable
@@ -75,26 +78,8 @@ const prompt = 'Extract the main heading and description.';
75
78
76
79
#### Scraping with Custom Output Schema
77
80
78
- ` ` ` typescript
79
- import { smartScraper } from ' scrapegraph-js' ;
80
-
81
- interface WebsiteData {
82
- title: string;
83
- description: string;
84
- }
85
-
86
- const apiKey = ' your-api-key' ;
87
- const url = ' https://example.com' ;
88
- const prompt = ' Extract the title and description.' ;
89
-
90
- (async () => {
91
- try {
92
- const response = await smartScraper< WebsiteData>( apiKey, url, prompt) ;
93
- console.log(response.result.title, response.result.description);
94
- } catch (error) {
95
- console.error(' Error:' , error);
96
- }
97
- })();
81
+ ``` javascript
82
+ // TODO
98
83
```
99
84
100
85
### Checking API Credits
0 commit comments