https://github.com/waylaidwanderer/php-rotatingproxymanager
A PHP library you can use to select proxies in a rotation.
https://github.com/waylaidwanderer/php-rotatingproxymanager
Last synced: 7 months ago
JSON representation
A PHP library you can use to select proxies in a rotation.
- Host: GitHub
- URL: https://github.com/waylaidwanderer/php-rotatingproxymanager
- Owner: waylaidwanderer
- License: mit
- Created: 2016-04-11T05:24:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-10T04:47:04.000Z (almost 9 years ago)
- Last Synced: 2025-02-28T21:06:54.358Z (7 months ago)
- Language: PHP
- Size: 15.6 KB
- Stars: 5
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP-RotatingProxyManager
A PHP library you can use to select proxies in a rotation. It uses SQLite to store proxy data so you can use multiple instances of `RotatingProxyManager` across multiple scripts and it will still work. Requires the SQLite extension for PHP to be installed.# Installation
`composer require waylaidwanderer/php-rotatingproxymanager`
# Usage
// supports proxies in the format "user:pass@ip:port" or simply "ip:port"
$list = [];
$proxiesFile = './proxies.txt';
$proxies = file($proxiesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($proxies as $proxy) {
$rotatingProxy = new RotatingProxy($proxy);
$rotatingProxy->setWaitInterval(2);
$list[] = $rotatingProxy;
}
$databaseFileLocation = __DIR__;
$proxyManager = new RotatingProxyManager($list, $databaseFileLocation);
$proxyToUse = $proxyManager->getNextProxy();
var_dump($proxyToUse->getUsername());
var_dump($proxyToUse->getPassword());
var_dump($proxyToUse->getIp());
var_dump($proxyToUse->getPort());
var_dump($proxyToUse->toString()); // will output "user:pass@ip:port" or just "ip:port"