1. Go to this page and download the library: Download ilmlv/proxy-scraper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ilmlv / proxy-scraper example snippets
use IlmLV\ProxyScraper\LoadProxies;
$proxies = LoadProxies::make()->all();
foreach ($proxies->get() as $proxy) {
echo $proxy . PHP_EOL;
}
dump($proxies->stats());
use IlmLV\ProxyScraper\LoadProxies;
$proxies = LoadProxies::make()->all();
foreach ($proxies->unique() as $proxy) {
echo $proxy . PHP_EOL;
}
use IlmLV\ProxyScraper\LoadProxies;
use IlmLV\ProxyScraper\Sources\FreeProxyListNet;
$proxies = LoadProxies::make()->only(FreeProxyListNet::class);
foreach ($proxies->get() as $proxy) {
echo $proxy . PHP_EOL;
}
use IlmLV\ProxyScraper\LoadProxies;
$proxies = LoadProxies::make()->scheduled();
foreach ($proxies->get() as $proxy) {
echo $proxy . PHP_EOL;
}
use IlmLV\ProxyScraper\LoadProxies;
use IlmLV\ProxyScraper\Scrapers\JsonScraper;
class CustomGimmeProxy extends JsonScraper
{
protected string $url = 'https://gimmeproxy.com/api/getProxy';
}
$proxies = LoadProxies::make()->only(CustomGimmeProxy::class);
foreach ($proxies->get() as $proxy) {
echo $proxy . PHP_EOL;
}
use IlmLV\ProxyScraper\Validations\ProxyValidation;
$validation = ProxyValidation::make('http://1.1.1.1:80')->run();
dump($validation);
$validation->http->get->valid; // forward GET worked
$validation->httpTunnel?->post->valid; // CONNECT-tunnel POST worked (null for SOCKS)
$validation->https->latency; // average HTTPS latency (seconds)
namespace IlmLV\ProxyScraper\Validations\Domains;
use IlmLV\ProxyScraper\Entities\ResponseError;
use Symfony\Component\DomCrawler\Crawler as Dom;
class ExampleCom extends AbstractDomainValidation
{
const NAME = 'example.com'; // result key, e.g. $validation->domains->{'example.com'}
const URL = 'http://example.com/';
public function validate(): bool
{
try {
$response = $this->request($this->method, $this->url);
$title = (new Dom($response->getContent()))->filter('title');
return $response->getStatusCode() === 200
&& $title->text() === 'Example Domain';
}
catch (\Throwable $e) {
$this->error = new ResponseError($e);
return false;
}
}
}
use IlmLV\ProxyScraper\Validations\Domains\ExampleCom;
use IlmLV\ProxyScraper\Validations\ProxyValidation;
$validation = ProxyValidation::make('http://1.1.1.1:80')
->setDomainValidators([
ExampleCom::class,
MyShop::class, // your own validator extending AbstractDomainValidation
])
->run();
$validation->domains->{'example.com'}->valid; // bool
use IlmLV\ProxyScraper\LoadProxies;
use IlmLV\ProxyScraper\Sources\FreeProxyListNet;
use IlmLV\ProxyScraper\Validations\ProxyValidation;
$proxies = LoadProxies::make()->only(FreeProxyListNet::class);
foreach ($proxies->get() as $proxy) {
$validation = ProxyValidation::make($proxy)->run();
dump(json_decode(json_encode($validation)));
}