@@ -9,11 +9,11 @@ Official JavaScript/TypeScript SDK for the ScrapeGraph AI API - Smart web scrapi
9
9
10
10
## 🚀 Features
11
11
12
- - ✨ Smart web scraping with AI
13
- - 🔄 Fully asynchronous design
14
- - 🔍 Detailed error handling
15
- - ⚡ Automatic retries and logging
16
- - 🔐 Secure API authentication
12
+ - ✨ Smart web scraping with AI
13
+ - 🔄 Fully asynchronous design
14
+ - 🔍 Detailed error handling
15
+ - ⚡ Automatic retries and logging
16
+ - 🔐 Secure API authentication
17
17
18
18
## 📦 Installation
19
19
@@ -23,11 +23,10 @@ Install the package using npm or yarn:
23
23
# Using npm
24
24
npm i scrapegraph-js
25
25
26
- # Using yarn
26
+ # Using yarn
27
27
yarn add scrapegraph-js
28
28
```
29
29
30
-
31
30
## 🔧 Quick Start
32
31
33
32
> ** Note** : Store your API keys securely in environment variables. Use ` .env ` files and libraries like ` dotenv ` to load them into your app.
@@ -36,7 +35,6 @@ yarn add scrapegraph-js
36
35
37
36
``` javascript
38
37
import { smartScraper } from ' scrapegraph-js' ;
39
- import ' dotenv/config' ;
40
38
41
39
// Initialize variables
42
40
const apiKey = process .env .SGAI_APIKEY ; // Set your API key as an environment variable
@@ -77,6 +75,7 @@ const prompt = 'Extract the main heading and description.';
77
75
```
78
76
79
77
#### Scraping with Custom Output Schema
78
+
80
79
> [ !NOTE]
81
80
> To use this feature, it is necessary to employ the [ Zod] ( https://www.npmjs.com/package/zod ) package for schema creation.
82
81
@@ -85,7 +84,6 @@ Here is a real-world example:
85
84
``` javascript
86
85
import { smartScraper } from ' scrapegraph-js' ;
87
86
import { z } from ' zod' ;
88
- import ' dotenv/config' ;
89
87
90
88
const apiKey = ' your-api-key' ;
91
89
const url = ' https://scrapegraphai.com/' ;
@@ -94,7 +92,7 @@ const prompt = 'What does the company do? and ';
94
92
const schema = z .object ({
95
93
title: z .string ().describe (' The title of the webpage' ),
96
94
description: z .string ().describe (' The description of the webpage' ),
97
- summary: z .string ().describe (' A brief summary of the webpage' )
95
+ summary: z .string ().describe (' A brief summary of the webpage' ),
98
96
});
99
97
100
98
(async () => {
@@ -107,6 +105,25 @@ const schema = z.object({
107
105
})();
108
106
```
109
107
108
+ ### Markdownify
109
+ Converts a webpage into clean, well-structured markdown format.
110
+ ``` javascript
111
+ import { smartScraper } from ' scrapegraph-js' ;
112
+
113
+ const apiKey = " your_api_key" ;
114
+ const url = ' https://scrapegraphai.com/' ;
115
+
116
+ (async () => {
117
+ try {
118
+ const response = await markdownify (apiKey, url);
119
+ console .log (response);
120
+ } catch (error) {
121
+ console .error (error);
122
+ }
123
+ })();
124
+ ```
125
+
126
+
110
127
### Checking API Credits
111
128
112
129
``` javascript
@@ -153,12 +170,14 @@ For detailed documentation, visit [docs.scrapegraphai.com](https://docs.scrapegr
153
170
### Setup
154
171
155
172
1 . Clone the repository:
173
+
156
174
``` bash
157
175
git clone https://github.com/ScrapeGraphAI/scrapegraph-sdk.git
158
176
cd scrapegraph-sdk/scrapegraph-js
159
177
```
160
178
161
179
2 . Install dependencies:
180
+
162
181
``` bash
163
182
npm install
164
183
```
@@ -187,22 +206,22 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
187
206
188
207
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
189
208
190
- 1 . Fork the repository
191
- 2 . Create your feature branch (` git checkout -b feature/AmazingFeature ` )
192
- 3 . Commit your changes (` git commit -m 'Add some AmazingFeature' ` )
193
- 4 . Push to the branch (` git push origin feature/AmazingFeature ` )
194
- 5 . Open a Pull Request
209
+ 1 . Fork the repository
210
+ 2 . Create your feature branch (` git checkout -b feature/AmazingFeature ` )
211
+ 3 . Commit your changes (` git commit -m 'Add some AmazingFeature' ` )
212
+ 4 . Push to the branch (` git push origin feature/AmazingFeature ` )
213
+ 5 . Open a Pull Request
195
214
196
215
## 🔗 Links
197
216
198
- - [ Website] ( https://scrapegraphai.com )
199
- - [ Documentation] ( https://scrapegraphai.com/documentation )
200
- - [ GitHub] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk )
217
+ - [ Website] ( https://scrapegraphai.com )
218
+ - [ Documentation] ( https://scrapegraphai.com/documentation )
219
+ - [ GitHub] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk )
201
220
202
221
## 💬 Support
203
222
204
-
205
- - 💻 GitHub Issues: [ Create an issue] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues )
223
+
224
+ - 💻 GitHub Issues: [ Create an issue] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues )
206
225
- 🌟 Feature Requests: [ Request a feature] ( https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues/new )
207
226
208
227
---
0 commit comments