Code Monkey home page Code Monkey logo

guzzlehttp-cloudflare's Introduction

logo

Guzzle Cloudflare Bypass

latest release

PayPal donation Buy me a coffee Become a Patron

(This product is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added.)

IMPORTANT NOTE: as KyranRana's dependency is actually not maintained anymore (https://github.com/KyranRana/cloudflare-bypass/commit/00d34f0050b817b858bbf5fd349b9911932f353f), this package won't be as-well. Thank you for your understanding. Please have a look at my other works (https://github.com/jaymoulin | https://twitch.tv/cursedware | https://patreon.com/jaymoulin | https://discord.gg/ujjrPCu | https://jaymoulin.me)

Bypass Cloudflare DDoS protection - Please use it carefully

This package is based on KyranRana's cloudflare-bypass.

Installation

Using composer

composer require jaymoulin/guzzlehttp-cloudflare

Usage

$sUrl = 'https://thebot.net/';
$oClient = new \GuzzleHttp\Client([
    'cookies' => new \GuzzleHttp\Cookie\FileCookieJar(tempnam('/tmp', __CLASS__)),
    'headers' => ['Referer' => $sUrl],
]); // 1. Create Guzzle instance
$aOptions = [
    'cache' => new \CloudflareBypass\Storage($sPathToYourCacheFolder),
]; // Example for cache, this is completely optional, with $sPathToYourCacheFolder a string to your cache folder
/** @var \GuzzleHttp\HandlerStack $oHandler */
$oHandler = $oClient->getConfig('handler');
$oHandler->push(\GuzzleCloudflare\Middleware::create($aOptions)); //2. ???

echo (string)$oClient->request('GET', $sUrl)->getBody(); //3. Profit!!

guzzlehttp-cloudflare's People

Contributors

jaymoulin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

guzzlehttp-cloudflare's Issues

Call to private method CloudflareBypass\RequestMethod\Stream::getHeader()

Description

When try to use with latest CloudflareBypass from Karyna's latest version.

Version you are using (you may find this information in your composer.lock file)
"kyranrana/cloudflare-bypass": "^v2.0",
"jaymoulin/guzzlehttp-cloudflare": "^0.2.0"

 Uncaught Error: Call to private method CloudflareBypass\RequestMethod\Stream::getHeader() from context 'GuzzleCloudflare\Middleware' in /var/www/fetch/vendor/jaymoulin/guzzlehttp-cloudflare/src/Middleware.php:116
Stack trace:
#0 /var/www/fetch/vendor/jaymoulin/guzzlehttp-cloudflare/src/Middleware.php(69): GuzzleCloudflare\Middleware->hackRequest(Object(GuzzleHttp\Psr7\Request))
#1 /var/www/fetch/vendor/jaymoulin/guzzlehttp-cloudflare/src/Middleware.php(54): GuzzleCloudflare\Middleware->checkResponse(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), Array)
#2 /var/www/fetch/vendor/guzzlehttp/promises/src/FulfilledPromise.php(39): GuzzleCloudflare\Middleware->GuzzleCloudflare\{closure}(Object(GuzzleHttp\Psr7\Response))
#3 /var/www/fetch/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\FulfilledPromise::GuzzleHttp\Promise\{closure}()
#4 /var/www/fetch/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\Promise\TaskQueue->run(true)
#5 /var/www/fetch/vendor/guzzlehttp/p in /var/www/fetch/vendor/jaymoulin/guzzlehttp-cloudflare/src/Middleware.php on line 116

How can I enable cache?

Caches clearance tokens so subsequent.
The default value of the cache variable is 'cache' => false
I guess I have to add 'cache' => new \CloudflareBypass\Storage(storage_path('cloudflare_cache')) but how and where can I write it?

Is it possible to reuse cookies for next request

If my guess is right, the current situation is a new cookies generated when a request made. Once the request ends, the cookies file delete.

Is it possible to reuse the cookies?

For example, I need to get a token from login page and post it along with username and password, that means I need to make a least two request. When I get proper token and post, it returns 503 error.

Thanks and best regards!

Add @ to tempnam()

Hi! I would like to request this information to be added in your README.md.

tempnam() will throw an exception in PHP 7.1.0 and above.
Placing an address operator @ to tempnam() will silence the exception.

$oClient = new \GuzzleHttp\Client([
    'cookies' => new \GuzzleHttp\Cookie\FileCookieJar(@tempnam('/tmp', __CLASS__)),
    'headers' => ['Referer' => $sUrl],
]); // 1. Create Guzzle instance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.