modstore / rotating-proxy-bundle
Rotating proxy bundle for Symfony.
Installs: 4 204
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1.0
- campo/random-user-agent: ^1.3
- doctrine/common: ~2.0
- fabpot/goutte: ^3.1
- guzzlehttp/guzzle: ~6.0
- symfony/framework-bundle: ~3.0
Requires (Dev)
- liip/functional-test-bundle: 1.2.2|~1.3
- phpunit/phpunit: 4.6.*
This package is auto-updated.
Last update: 2025-01-06 12:47:31 UTC
README
This bundle rotates through your pool of http proxies when sending subsequent requests.
Installation
composer require modstore/rotating-proxy-bundle:dev-master
Add RotatingProxyBundle to your application kernel
// app/AppKernel.php public function registerBundles() { return array( // ... new Modstore\RotatingProxyBundle\ModstoreRotatingProxyBundle(), // ... ); }
Add your proxy pool
Add your proxy ip addresses to the db table: modstore_rotating_proxy
- host: The proxy IP address
- port: The proxy port
- status: 1 to enable, 0 to disable
Usage example
/** @var \Symfony\Component\DomCrawler\Crawler $crawler */ $crawler = $container->get('modstore_rotating_proxy.manager')->crawlPage( 'https://github.com/modstore/RotatingProxyBundle', 'github', ['Referer' => 'https://www.google.com'] );
An instance of the Symfony dom crawler will be returned: https://symfony.com/doc/current/components/dom_crawler.html
Notes
In order to ensure requests aren't too similar and blocked as a bot, each request will set a random user agent string. It is also a good idea to provide a "Referer" string that would be a plausible organic referrer to the page you're requesting.
The second argument is a group name. Requests are rotated within a group. Generally for all requests to a particular domain, you would set the same group name.
Test command
There's a test command to see how it works and test your requests. The text from the body of the page will be output.
php bin/console modstore_rotating_proxy:test
Optionally a url can be provided:
php bin/console modstore_rotating_proxy:test --url='https://github.com/modstore/RotatingProxyBundle'
When the url argument is omitted, a request will be sent to whatsmyip.org.
Log
A log of all requests is stored in the modstore_rotating_proxy_log table.