Skip to content

Commit 5c43dc4

Browse files
committed
style: Improve formatting and style
1 parent bc08dcb commit 5c43dc4

File tree

10 files changed

+57
-55
lines changed

10 files changed

+57
-55
lines changed

scrapegraph-js/CODE_OF_CONDUCT.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
1717
Examples of behavior that contributes to a positive environment for our
1818
community include:
1919

20-
* Demonstrating empathy and kindness toward other people
21-
* Being respectful of differing opinions, viewpoints, and experiences
22-
* Giving and gracefully accepting constructive feedback
23-
* Accepting responsibility and apologizing to those affected by our mistakes,
20+
- Demonstrating empathy and kindness toward other people
21+
- Being respectful of differing opinions, viewpoints, and experiences
22+
- Giving and gracefully accepting constructive feedback
23+
- Accepting responsibility and apologizing to those affected by our mistakes,
2424
and learning from the experience
25-
* Focusing on what is best not just for us as individuals, but for the
25+
- Focusing on what is best not just for us as individuals, but for the
2626
overall community
2727

2828
Examples of unacceptable behavior include:
2929

30-
* The use of sexualized language or imagery, and sexual attention or
30+
- The use of sexualized language or imagery, and sexual attention or
3131
advances of any kind
32-
* Trolling, insulting or derogatory comments, and personal or political attacks
33-
* Public or private harassment
34-
* Publishing others' private information, such as a physical or email
32+
- Trolling, insulting or derogatory comments, and personal or political attacks
33+
- Public or private harassment
34+
- Publishing others' private information, such as a physical or email
3535
address, without their explicit permission
36-
* Other conduct which could reasonably be considered inappropriate in a
36+
- Other conduct which could reasonably be considered inappropriate in a
3737
professional setting
3838

3939
## Enforcement Responsibilities
@@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
106106
### 4. Permanent Ban
107107

108108
**Community Impact**: Demonstrating a pattern of violation of community
109-
standards, including sustained inappropriate behavior, harassment of an
109+
standards, including sustained inappropriate behavior, harassment of an
110110
individual, or aggression toward or disparagement of classes of individuals.
111111

112112
**Consequence**: A permanent ban from any sort of public interaction within

scrapegraph-js/README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Official JavaScript/TypeScript SDK for the ScrapeGraph AI API - Smart web scrapi
99

1010
## 🚀 Features
1111

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
1717

1818
## 📦 Installation
1919

@@ -23,11 +23,10 @@ Install the package using npm or yarn:
2323
# Using npm
2424
npm i scrapegraph-js
2525

26-
# Using yarn
26+
# Using yarn
2727
yarn add scrapegraph-js
2828
```
2929

30-
3130
## 🔧 Quick Start
3231

3332
> **Note**: Store your API keys securely in environment variables. Use `.env` files and libraries like `dotenv` to load them into your app.
@@ -77,6 +76,7 @@ const prompt = 'Extract the main heading and description.';
7776
```
7877

7978
#### Scraping with Custom Output Schema
79+
8080
> [!NOTE]
8181
> To use this feature, it is necessary to employ the [Zod](https://www.npmjs.com/package/zod) package for schema creation.
8282
@@ -94,7 +94,7 @@ const prompt = 'What does the company do? and ';
9494
const schema = z.object({
9595
title: z.string().describe('The title of the webpage'),
9696
description: z.string().describe('The description of the webpage'),
97-
summary: z.string().describe('A brief summary of the webpage')
97+
summary: z.string().describe('A brief summary of the webpage'),
9898
});
9999

100100
(async () => {
@@ -153,12 +153,14 @@ For detailed documentation, visit [docs.scrapegraphai.com](https://docs.scrapegr
153153
### Setup
154154

155155
1. Clone the repository:
156+
156157
```bash
157158
git clone https://github.com/ScrapeGraphAI/scrapegraph-sdk.git
158159
cd scrapegraph-sdk/scrapegraph-js
159160
```
160161

161162
2. Install dependencies:
163+
162164
```bash
163165
npm install
164166
```
@@ -187,22 +189,22 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
187189

188190
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.
189191

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
192+
1. Fork the repository
193+
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
194+
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
195+
4. Push to the branch (`git push origin feature/AmazingFeature`)
196+
5. Open a Pull Request
195197

196198
## 🔗 Links
197199

198-
- [Website](https://scrapegraphai.com)
199-
- [Documentation](https://scrapegraphai.com/documentation)
200-
- [GitHub](https://github.com/ScrapeGraphAI/scrapegraph-sdk)
200+
- [Website](https://scrapegraphai.com)
201+
- [Documentation](https://scrapegraphai.com/documentation)
202+
- [GitHub](https://github.com/ScrapeGraphAI/scrapegraph-sdk)
201203

202204
## 💬 Support
203205

204-
- 📧 Email: [email protected]
205-
- 💻 GitHub Issues: [Create an issue](https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues)
206+
- 📧 Email: [email protected]
207+
- 💻 GitHub Issues: [Create an issue](https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues)
206208
- 🌟 Feature Requests: [Request a feature](https://github.com/ScrapeGraphAI/scrapegraph-sdk/issues/new)
207209

208210
---

scrapegraph-js/examples/getCredits_example.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'dotenv/config';
44
const apiKey = process.env.SGAI_APIKEY;
55

66
try {
7-
const myCredit = await getCredits(apiKey);
8-
console.log(myCredit)
7+
const myCredit = await getCredits(apiKey);
8+
console.log(myCredit);
99
} catch (error) {
10-
console.error(error)
11-
}
10+
console.error(error);
11+
}

scrapegraph-js/examples/getSmartScraperRequest_example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { getSmartScraperRequest } from 'scrapegraph-js';
22
import 'dotenv/config';
33

44
const apiKey = process.env.SGAI_APIKEY;
5-
const requestId = '3fa85f64-5717-4562-b3fc-2c963f66afa6'
5+
const requestId = '3fa85f64-5717-4562-b3fc-2c963f66afa6';
66

77
try {
88
const requestInfo = await getSmartScraperRequest(apiKey, requestId);
99
console.log(requestInfo);
1010
} catch (error) {
1111
console.error(error);
12-
}
12+
}

scrapegraph-js/examples/sendFeedback_example.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ try {
1010
const feedback_response = await sendFeedback(apiKey, requestId, rating, feedbackMessage);
1111
console.log(feedback_response);
1212
} catch (error) {
13-
console.error(error)
14-
}
13+
console.error(error);
14+
}

scrapegraph-js/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { smartScraper, getSmartScraperRequest } from './src/smartScraper.js';
22
export { getCredits } from './src/credits.js';
3-
export { sendFeedback } from './src/feedback.js';
3+
export { sendFeedback } from './src/feedback.js';

scrapegraph-js/src/credits.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import handleError from './utils/handleError.js';
33

44
/**
55
* Retrieve credits from the API.
6-
*
6+
*
77
* @param {string} apiKey - Your ScrapeGraph AI API key
88
* @returns {Promise<string>} Response from the API in JSON format
99
*/
1010
export async function getCredits(apiKey) {
1111
const endpoint = 'https://api.scrapegraphai.com/v1/credits';
1212
const headers = {
1313
'accept': 'application/json',
14-
'SGAI-APIKEY': apiKey
14+
'SGAI-APIKEY': apiKey,
1515
};
1616

1717
try {
1818
const response = await axios.get(endpoint, { headers });
1919
return response.data;
2020
} catch (error) {
21-
handleError(error)
21+
handleError(error);
2222
}
23-
}
23+
}

scrapegraph-js/src/feedback.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import handleError from './utils/handleError.js';
33

44
/**
55
* Send feedback to the API.
6-
*
6+
*
77
* @param {string} apiKey - Your ScrapeGraph AI API key
88
* @param {string} requestId - The request ID associated with the feedback
99
* @param {number} rating - The rating score
@@ -15,13 +15,13 @@ export async function sendFeedback(apiKey, requestId, rating, feedbackText = nul
1515
const headers = {
1616
'accept': 'application/json',
1717
'SGAI-APIKEY': apiKey,
18-
'Content-Type': 'application/json'
18+
'Content-Type': 'application/json',
1919
};
2020

2121
const feedbackData = {
2222
request_id: requestId,
2323
rating: rating,
24-
feedback_text: feedbackText
24+
feedback_text: feedbackText,
2525
};
2626

2727
try {
@@ -30,4 +30,4 @@ export async function sendFeedback(apiKey, requestId, rating, feedbackText = nul
3030
} catch (error) {
3131
handleError(error);
3232
}
33-
}
33+
}

scrapegraph-js/src/smartScraper.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { zodToJsonSchema } from 'zod-to-json-schema';
55

66
/**
77
* Scrape and extract structured data from a webpage using ScrapeGraph AI.
8-
*
8+
*
99
* @param {string} apiKey - Your ScrapeGraph AI API key
1010
* @param {string} url - The URL of the webpage to scrape
1111
* @param {string} prompt - Natural language prompt describing what data to extract
@@ -18,12 +18,12 @@ export async function smartScraper(apiKey, url, prompt, schema = null) {
1818
const headers = {
1919
'accept': 'application/json',
2020
'SGAI-APIKEY': apiKey,
21-
'Content-Type': 'application/json'
21+
'Content-Type': 'application/json',
2222
};
2323

2424
const payload = {
2525
website_url: url,
26-
user_prompt: prompt
26+
user_prompt: prompt,
2727
};
2828

2929
if (schema) {
@@ -38,13 +38,13 @@ export async function smartScraper(apiKey, url, prompt, schema = null) {
3838
const response = await axios.post(endpoint, payload, { headers });
3939
return response.data;
4040
} catch (error) {
41-
handleError(error)
41+
handleError(error);
4242
}
4343
}
4444

4545
/**
4646
* Retrieve the status or the result of a smartScraper request. It also allows you to see the result of old requests.
47-
*
47+
*
4848
* @param {string} apiKey - Your ScrapeGraph AI API key
4949
* @param {string} requestId - The request ID associated with the output of a smartScraper request.
5050
* @returns {Promise<string>} Information related to the status or result of a scraping request.
@@ -60,6 +60,6 @@ export async function getSmartScraperRequest(apiKey, requestId) {
6060
const response = await axios.get(endpoint, { headers });
6161
return response.data;
6262
} catch (error) {
63-
handleError(error)
63+
handleError(error);
6464
}
65-
}
65+
}

scrapegraph-js/src/utils/handleError.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class UnexpectedError extends Error {
3131

3232
export default function handleError(error) {
3333
if (error.response) {
34-
throw new HttpError(error.response.status, error.response.statusText, error.response.data.detail)
34+
throw new HttpError(error.response.status, error.response.statusText, error.response.data.detail);
3535
} else if (error.request) {
3636
throw new NetworkError('Impossible to contact the server. Check your internet connection.');
3737
} else {
3838
throw new UnexpectedError(`${error.message}`);
3939
}
40-
}
40+
}

0 commit comments

Comments
 (0)