Skip to content

Commit adb926e

Browse files
committed
feat: add files
1 parent f728b05 commit adb926e

File tree

4 files changed

+921
-0
lines changed

4 files changed

+921
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,54 @@ $response = $client->request(
176176
);
177177
```
178178

179+
## Examples
180+
181+
The `examples/` directory contains comprehensive examples demonstrating various use cases:
182+
183+
### Basic Examples
184+
- **[SmartScraper](examples/basic/basic-smartscraper.php)** - Extract data from web pages using natural language prompts
185+
- **[Markdownify](examples/basic/basic-markdownify.php)** - Convert web pages to clean Markdown format
186+
- **[SearchScraper](examples/basic/basic-searchscraper.php)** - Search and scrape data from multiple websites
187+
- **[Crawl](examples/basic/basic-crawl.php)** - Systematically crawl entire websites
188+
- **[Generate Schema](examples/basic/basic-schema.php)** - Generate JSON schemas from natural language
189+
- **[Credits](examples/basic/basic-credits.php)** - Check your API credit balance
190+
- **[Validate](examples/basic/basic-validate.php)** - Validate your API key
191+
192+
### Advanced Examples
193+
- **[Advanced SmartScraper](examples/advanced/advanced-smartscraper.php)** - Complex schemas, JavaScript rendering, pagination
194+
- **[Error Handling](examples/advanced/advanced-error-handling.php)** - Comprehensive error handling strategies
195+
196+
### Real-World Use Cases
197+
- **[E-commerce Scraper](examples/use-cases/ecommerce-scraper.php)** - Product monitoring, price comparison, review analysis
198+
- **[News Aggregator](examples/use-cases/news-aggregator.php)** - Multi-source news monitoring, sentiment analysis
199+
- **[Job Listings](examples/use-cases/job-listings.php)** - Job search aggregation, salary benchmarking, skills analysis
200+
201+
### Quick Start Example
202+
203+
```php
204+
<?php
205+
require_once 'vendor/autoload.php';
206+
207+
use Scrapegraphai\Client;
208+
use Scrapegraphai\Smartscraper\SmartscraperCreateParams;
209+
210+
// Initialize client
211+
$client = new Client(
212+
apiKey: getenv('SCRAPEGRAPHAI_API_KEY')
213+
);
214+
215+
// Extract product information
216+
$params = SmartscraperCreateParams::from(
217+
userPrompt: "Extract the product name, price, and rating",
218+
websiteURL: "https://example-store.com/product"
219+
);
220+
221+
$result = $client->smartscraper->create($params);
222+
echo json_encode($result->data, JSON_PRETTY_PRINT);
223+
```
224+
225+
For more examples and detailed documentation, see the [examples directory](examples/).
226+
179227
## Versioning
180228

181229
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.

examples/composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "scrapegraphai/examples",
3+
"description": "Examples for the ScrapeGraphAI PHP SDK",
4+
"type": "project",
5+
"require": {
6+
"php": "^8.1",
7+
"org-placeholder/scrapegraphai": "dev-main"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Examples\\": "src/"
12+
}
13+
},
14+
"repositories": [
15+
{
16+
"type": "path",
17+
"url": "../"
18+
}
19+
],
20+
"minimum-stability": "dev",
21+
"prefer-stable": true
22+
}

0 commit comments

Comments
 (0)