Skip to content

Commit 89ec685

Browse files
committed
feat: add group of code
1 parent e7c532f commit 89ec685

File tree

9 files changed

+297
-15
lines changed

9 files changed

+297
-15
lines changed

.DS_Store

6 KB
Binary file not shown.

api-reference/openapi.json

+16-8
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
{
6565
"lang": "python",
6666
"label": "Python",
67-
"source": "import requests\n\nurl = 'https://api.scrapegraphai.com/v1/smartscraper'\nheaders = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n}\npayload = {\n 'user_prompt': 'Extract info about the company',\n 'website_url': 'https://scrapegraphai.com/'\n}\n\nresponse = requests.post(url, json=payload, headers=headers)\ndata = response.json()"
67+
"source": "from scrapegraph_py import Client\n\nclient = Client(api_key=\"your-api-key\")\n\nresponse = client.smartscraper(\n website_url=\"https://scrapegraphai.com/\",\n user_prompt=\"Extract info about the company\"\n)"
6868
},
6969
{
7070
"lang": "javascript",
7171
"label": "JavaScript",
72-
"source": "const url = 'https://api.scrapegraphai.com/v1/smartscraper';\nconst headers = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n};\nconst payload = {\n user_prompt: 'Extract info about the company',\n website_url: 'https://scrapegraphai.com/'\n};\n\nfetch(url, {\n method: 'POST',\n headers: headers,\n body: JSON.stringify(payload)\n})\n .then(response => response.json())\n .then(data => console.log(data));"
72+
"source": "import { Client } from 'scrapegraph-js';\n\n // Initialize the client\nconst sgai_client = new Client(\"your-api-key\");\n\n try {\n const response = await sgai_client.smartscraper({\n websiteUrl: \"https://example-shop.com/products/456\",\n userPrompt: \"Extract product details including name, price, availability, specifications, and customer ratings.\"\n });\n\n console.log('Request ID:', response.requestId);\n console.log('Result:', response.result);\n} catch (error) {\n console.error(error);\n} finally {\n sgai_client.close();\n}"
7373
}
7474
]
7575
}
@@ -128,13 +128,14 @@
128128
{
129129
"lang": "python",
130130
"label": "Python",
131-
"source": "import requests\n\nurl = 'https://api.scrapegraphai.com/v1/smartscraper/YOUR_REQUEST_ID'\nheaders = {\n 'SGAI-APIKEY': 'YOUR_API_KEY'\n}\n\nresponse = requests.get(url, headers=headers)\ndata = response.json()"
132-
},
131+
"source": "ciao"
132+
},
133133
{
134134
"lang": "javascript",
135135
"label": "JavaScript",
136136
"source": "const url = 'https://api.scrapegraphai.com/v1/smartscraper/YOUR_REQUEST_ID';\nconst headers = {\n 'SGAI-APIKEY': 'YOUR_API_KEY'\n};\n\nfetch(url, { headers })\n .then(response => response.json())\n .then(data => console.log(data));"
137137
}
138+
138139
]
139140
}
140141
},
@@ -191,12 +192,12 @@
191192
{
192193
"lang": "python",
193194
"label": "Python",
194-
"source": "import requests\n\nurl = 'https://api.scrapegraphai.com/v1/markdownify'\nheaders = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n}\npayload = {\n 'website_url': 'https://scrapegraphai.com/'\n}\n\nresponse = requests.post(url, json=payload, headers=headers)\ndata = response.json()"
195+
"source": "from scrapegraph_py import Client\n\nclient = Client(api_key=\"your-api-key\")\n\nresponse = client.markdownify(\n website_url=\"https://scrapegraphai.com/\"\n)"
195196
},
196197
{
197198
"lang": "javascript",
198199
"label": "JavaScript",
199-
"source": "const url = 'https://api.scrapegraphai.com/v1/markdownify';\nconst headers = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n};\nconst payload = {\n website_url: 'https://scrapegraphai.com/'\n};\n\nfetch(url, {\n method: 'POST',\n headers: headers,\n body: JSON.stringify(payload)\n})\n .then(response => response.json())\n .then(data => console.log(data));"
200+
"source": "import { Client } from 'scrapegraph-js';\n\n// Initialize the client\nconst sgai_client = new Client(\"your-api-key\");\n\ntry {\n const response = await sgai_client.markdownify({\n websiteUrl: \"https://example-shop.com/products/456\",\n userPrompt: \"Extract product details including name, price, availability, specifications, and customer ratings.\"\n });\n\n console.log('Request ID:', response.requestId);\n console.log('Result:', response.result);\n} catch (error) {\n console.error(error);\n} finally {\n sgai_client.close();\n}"
200201
}
201202
]
202203
}
@@ -372,6 +373,13 @@
372373
}
373374
},
374375
"/v1/searchscraper": {
376+
"get": {
377+
"tags": [
378+
"SearchScraper"
379+
],
380+
"summary": "Get Searchscraper Status",
381+
"operationId": "get_searchscraper_status_v1_searchscraper__request_id__get",
382+
},
375383
"post": {
376384
"tags": [
377385
"SearchScraper"
@@ -424,12 +432,12 @@
424432
{
425433
"lang": "python",
426434
"label": "Python",
427-
"source": "import requests\nimport time\n\ndef search_and_wait(prompt, output_schema=None, max_retries=30, delay=2):\n \"\"\"Search for information and wait for results\n \n Args:\n prompt (str): Natural language query\n output_schema (dict, optional): Schema to structure the response\n max_retries (int): Maximum number of status checks\n delay (int): Seconds to wait between status checks\n \"\"\"\n url = 'https://api.scrapegraphai.com/v1/searchscraper'\n headers = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n }\n \n # Prepare the request payload\n payload = {\n 'user_prompt': prompt,\n 'headers': {\n 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'\n }\n }\n \n # Add output schema if provided\n if output_schema:\n payload['output_schema'] = output_schema\n \n # Start the search\n response = requests.post(url, json=payload, headers=headers)\n \n if response.status_code != 200:\n raise Exception(f'Failed to start search: {response.text}')\n \n data = response.json()\n request_id = data['request_id']\n print(f'Search started with request ID: {request_id}')\n \n # Poll for results\n for attempt in range(max_retries):\n status_url = f'{url}/{request_id}'\n status_response = requests.get(status_url, headers=headers)\n status_data = status_response.json()\n \n if status_data['status'] == 'completed':\n print('\\nSearch completed successfully!')\n print('\\nResults:')\n print('--------')\n print(f\"Answer: {status_data['result'].get('answer')}\")\n if 'details' in status_data['result']:\n print('\\nDetails:')\n for key, value in status_data['result']['details'].items():\n print(f'{key}: {value}')\n print('\\nReference URLs:')\n for url in status_data['reference_urls']:\n print(f'- {url}')\n return status_data\n \n elif status_data['status'] == 'failed':\n raise Exception(f'Search failed: {status_data.get(\"error\", \"Unknown error\")}')\n \n print(f'Status: {status_data[\"status\"]}... (attempt {attempt + 1}/{max_retries})', end='\\r')\n time.sleep(delay)\n \n raise TimeoutError(f'Search did not complete after {max_retries * delay} seconds')\n\n# Example usage\ntry:\n # Define the output schema for structured results\n schema = {\n 'answer': 'string',\n 'details': {\n 'version': 'string',\n 'release_date': 'string',\n 'download_url': 'string'\n }\n }\n \n # Run the search with the schema\n results = search_and_wait(\n prompt='What is the latest version of Python?',\n output_schema=schema\n )\n \n # Access specific fields from the structured response\n version = results['result']['details']['version']\n release_date = results['result']['details']['release_date']\n \n # Use the data in your application\n print(f'\\nPython {version} was released on {release_date}')\n \nexcept Exception as e:\n print(f'Error: {str(e)}')"
435+
"source": "from scrapegraph_py import Client\n\nclient = Client(api_key=\"your-api-key\")\n\nresponse = client.searchscraper(\n user_prompt=\"What is the latest version of Python?\",\n output_schema={\n \"answer\": \"string\",\n \"details\": {\n \"version\": \"string\",\n \"release_date\": \"string\",\n \"download_url\": \"string\"\n }\n }\n)"
428436
},
429437
{
430438
"lang": "javascript",
431439
"label": "JavaScript",
432-
"source": "const url = 'https://api.scrapegraphai.com/v1/searchscraper';\nconst headers = {\n 'SGAI-APIKEY': 'YOUR_API_KEY',\n 'Content-Type': 'application/json'\n};\nconst payload = {\n user_prompt: 'What is the latest version of Python?',\n output_schema: {\n answer: 'string',\n details: {\n version: 'string',\n release_date: 'string',\n download_url: 'string'\n }\n }\n};\n\nfetch(url, {\n method: 'POST',\n headers: headers,\n body: JSON.stringify(payload)\n})\n .then(response => response.json())\n .then(data => console.log(data));"
440+
"source": "import { Client } from 'scrapegraph-js';\n\n// Initialize the client\nconst sgai_client = new Client(\"your-api-key\");\n\ntry {\n const response = await sgai_client.searchscraper({\n userPrompt: \"What is the latest version of Python?\",\n outputSchema: {\n answer: \"string\",\n details: {\n version: \"string\",\n release_date: \"string\",\n download_url: \"string\"\n }\n }\n });\n\n console.log('Request ID:', response.requestId);\n console.log('Result:', response.result);\n} catch (error) {\n console.error(error);\n} finally {\n sgai_client.close();\n}"
433441
}
434442
]
435443
}

mint.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
{
9595
"group": "Browser Extensions",
9696
"pages": [
97-
98-
"services/extensions/firefox"
97+
"services/extensions/firefox",
98+
"services/extensions/chrome"
9999
]
100100
}
101101
]

services/.DS_Store

6 KB
Binary file not shown.

services/extensions/chrome.mdx

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: 'Chrome'
3+
description: 'Extract data from any webpage directly in your browser'
4+
icon: 'chrome'
5+
---
6+
7+
## Overview
8+
9+
The ScrapeGraphAI Chrome Extension brings the power of our AI-driven data extraction directly to your browser. With a simple prompt, you can extract structured data from any webpage you're visiting, making web research and data collection effortless.
10+
11+
<Note>
12+
Install the extension from the [Chrome Web Store](https://chromewebstore.google.com/detail/scrapegraphai/keccjglpnpkialnoaoigiboeghioehfb)
13+
</Note>
14+
15+
<Frame>
16+
<img src="/services/images/chrome-extension.png" alt="ScrapeGraphAI Chrome Extension" />
17+
</Frame>
18+
19+
20+
## Key Features
21+
22+
<CardGroup cols={2}>
23+
<Card title="One-Click Access" icon="mouse-pointer">
24+
Extract data from any webpage with a single click
25+
</Card>
26+
<Card title="Natural Language Prompts" icon="comments">
27+
Describe what you want to extract in plain English
28+
</Card>
29+
<Card title="Structured Output" icon="table">
30+
Get clean, structured JSON data
31+
</Card>
32+
<Card title="Browser Integration" icon="browser">
33+
Seamless integration with your browsing experience
34+
</Card>
35+
</CardGroup>
36+
37+
## Getting Started
38+
39+
### API Key Setup
40+
41+
First, you'll need to get your ScrapeGraphAI API key:
42+
43+
<Frame>
44+
<img src="/services/images/chrome-api-key.png" alt="Chrome Extension API Key Setup" />
45+
</Frame>
46+
47+
1. Get your API key from the [dashboard](https://dashboard.scrapegraphai.com)
48+
2. Click the ScrapeGraphAI icon in your toolbar
49+
3. Enter your API key in the settings
50+
4. Click Save to store your API key securely
51+
52+
### Usage
53+
54+
Once your API key is set up, you can start extracting data:
55+
56+
<Frame>
57+
<img src="/services/images/firefox-main-view.png" alt="Chrome Extension Main View" />
58+
</Frame>
59+
60+
1. Navigate to any webpage you want to extract data from
61+
2. Click the ScrapeGraphAI icon in your toolbar
62+
3. Enter your prompt describing what information you want to extract
63+
4. Click Extract to receive structured JSON data based on your prompt
64+
65+
### Example: Reddit Posts Extraction
66+
67+
Here's an example of extracting posts from Reddit:
68+
69+
```text
70+
"List me all the posts in the page, extracting title, post url, image url, upvotes and comments"
71+
```
72+
73+
The extension will return structured JSON data like this:
74+
75+
```json
76+
{
77+
"posts": [
78+
{
79+
"title": "Example Reddit Post Title",
80+
"post_url": "https://reddit.com/r/example/post1",
81+
"image_url": "https://i.redd.it/example1.jpg",
82+
"upvotes": 1234,
83+
"comments": 56
84+
},
85+
{
86+
"title": "Another Reddit Post",
87+
"post_url": "https://reddit.com/r/example/post2",
88+
"image_url": "https://i.redd.it/example2.jpg",
89+
"upvotes": 789,
90+
"comments": 23
91+
}
92+
// ... more posts
93+
]
94+
}
95+
```
96+
97+
## Example Use Cases
98+
99+
### Research
100+
- Extract company information
101+
- Gather product details
102+
- Collect article data
103+
- Compile contact information
104+
105+
### Data Collection
106+
- Market research
107+
- Competitive analysis
108+
- Content aggregation
109+
- Price monitoring
110+
111+
### Personal Use
112+
- Save article summaries
113+
- Extract recipe ingredients
114+
- Compile reading lists
115+
- Save product comparisons
116+
117+
## Example Prompts
118+
119+
Here are some example prompts you can use with the extension:
120+
121+
```text
122+
"Extract the main article content, author, and publication date"
123+
"Get all product information including price, features, and specifications"
124+
"Find all contact information including email, phone, and social media links"
125+
"Extract company information including location, size, and industry"
126+
```
127+
128+
## Best Practices
129+
130+
### Writing Effective Prompts
131+
1. Be specific about what you want to extract
132+
2. Include all relevant fields in your prompt
133+
3. Use clear, natural language
134+
4. Consider the structure of your desired output
135+
136+
### Tips for Better Results
137+
- Wait for the page to load completely before extraction
138+
- Ensure you have access to all content you want to extract
139+
- Use specific terminology when requesting technical information
140+
- Review the extracted data for accuracy
141+
142+
## Privacy & Security
143+
144+
- The extension only accesses webpage content when explicitly triggered
145+
- Data is processed securely through ScrapeGraphAI's servers
146+
- No personal browsing data is stored or tracked
147+
- Complies with Google's Chrome Web Store policies
148+
149+
## Support & Resources
150+
151+
<CardGroup cols={2}>
152+
<Card title="Documentation" icon="book" href="/introduction">
153+
Comprehensive guides and tutorials
154+
</Card>
155+
<Card title="Community" icon="discord" href="https://discord.gg/uJN7TYcpNa">
156+
Join our Discord community
157+
</Card>
158+
<Card title="GitHub" icon="github" href="https://github.com/ScrapeGraphAI">
159+
Check out our open-source projects
160+
</Card>
161+
<Card title="Support" icon="headset" href="mailto:[email protected]">
162+
Get help with the extension
163+
</Card>
164+
</CardGroup>
165+
166+
<Card title="Ready to Start?" icon="rocket" href="https://chrome.google.com/webstore/detail/scrapegraphai-extension">
167+
Install the Chrome extension now and start extracting data with ease!
168+
</Card>

services/images/chrome-extension.png

1.37 MB
Loading

services/markdownify.mdx

+36-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ Try Markdownify instantly in our [interactive playground](https://dashboard.scra
2020

2121
### Quick Start
2222

23-
```python
23+
<CodeGroup>
24+
25+
```python Python
2426
from scrapegraph_py import Client
2527

2628
client = Client(api_key="your-api-key")
@@ -30,6 +32,39 @@ response = client.markdownify(
3032
)
3133
```
3234

35+
```javascript JavaScript
36+
import { Client } from 'scrapegraph-js';
37+
38+
// Initialize the client
39+
const sgai_client = new Client("your-api-key");
40+
41+
try {
42+
const response = await sgai_client.markdownify({
43+
websiteUrl: "https://example.com"
44+
});
45+
46+
console.log('Request ID:', response.requestId);
47+
console.log('Result:', response.result);
48+
} catch (error) {
49+
console.error(error);
50+
} finally {
51+
sgai_client.close();
52+
}
53+
```
54+
55+
```bash cURL
56+
curl -X 'POST' \
57+
'https://api.scrapegraphai.com/v1/markdownify' \
58+
-H 'accept: application/json' \
59+
-H 'SGAI-APIKEY: your-api-key' \
60+
-H 'Content-Type: application/json' \
61+
-d '{
62+
"website_url": "https://example.com"
63+
}'
64+
```
65+
66+
</CodeGroup>
67+
3368
<Note>
3469
Get your API key from the [dashboard](https://dashboard.scrapegraphai.com)
3570
</Note>

services/searchscraper.mdx

+37-3
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,51 @@ Try SearchScraper instantly in our [interactive playground](https://dashboard.sc
2020

2121
### Quick Start
2222

23-
```python
23+
<CodeGroup>
24+
25+
```python Python
2426
from scrapegraph_py import Client
2527

2628
client = Client(api_key="your-api-key")
2729

28-
# Execute search with schema
2930
response = client.searchscraper(
30-
user_prompt="What are the key features and pricing of ChatGPT Plus?",
31+
user_prompt="What are the key features and pricing of ChatGPT Plus?"
3132
)
3233
```
3334

35+
```javascript JavaScript
36+
import { Client } from 'scrapegraph-js';
37+
38+
// Initialize the client
39+
const sgai_client = new Client("your-api-key");
40+
41+
try {
42+
const response = await sgai_client.searchscraper({
43+
userPrompt: "Search for information"
44+
});
45+
46+
console.log('Request ID:', response.requestId);
47+
console.log('Result:', response.result);
48+
} catch (error) {
49+
console.error(error);
50+
} finally {
51+
sgai_client.close();
52+
}
53+
```
54+
55+
```bash cURL
56+
curl -X 'POST' \
57+
'https://api.scrapegraphai.com/v1/searchscraper' \
58+
-H 'accept: application/json' \
59+
-H 'SGAI-APIKEY: your-api-key' \
60+
-H 'Content-Type: application/json' \
61+
-d '{
62+
"user_prompt": "Search for information"
63+
}'
64+
```
65+
66+
</CodeGroup>
67+
3468
<Note>
3569
Get your API key from the [dashboard](https://dashboard.scrapegraphai.com)
3670
</Note>

0 commit comments

Comments
 (0)