Skip to content

Commit

Permalink
~ readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vantoozz committed Mar 6, 2021
1 parent 73beb4b commit 7e05a0d
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions README.md
Expand Up @@ -243,34 +243,16 @@ returns an instance of `CompositeScraper`:
```php
<?php declare(strict_types=1);

use Vantoozz\ProxyScraper\Exceptions\ValidationException;
use Vantoozz\ProxyScraper\Ipv4;
use Vantoozz\ProxyScraper\Port;
use Vantoozz\ProxyScraper\Proxy;
use Vantoozz\ProxyScraper\Scrapers;
use Vantoozz\ProxyScraper\Validators;
use Vantoozz\ProxyScraper\Exceptions\ScraperException;
use function Vantoozz\ProxyScraper\proxyScraper;

require_once __DIR__ . '/vendor/autoload.php';

$scraper = new class implements Scrapers\ScraperInterface {
public function get(): Generator
{
yield new Proxy(new Ipv4('104.202.117.106'), new Port(1234));
yield new Proxy(new Ipv4('192.168.0.1'), new Port(8888));
}
};

$validator = new Validators\ValidatorPipeline;
$validator->addStep(new Validators\Ipv4RangeValidator);
$scraper = proxyScraper();

foreach ($scraper->get() as $proxy) {
try {
$validator->validate($proxy);
echo '[OK] ' . $proxy . "\n";
} catch (ValidationException $e) {
echo '[Error] ' . $e->getMessage() . ': ' . $proxy . "\n";
}
}
$scraper->handleScraperExceptionWith(function (ScraperException $e) {
echo 'An error occurs: ' . $e->getMessage() . "\n";
});
```

#### Validating proxies
Expand Down

0 comments on commit 7e05a0d

Please sign in to comment.