lantosbro/guzzlehttp-cloudflare

使用GuzzleHTTP绕过Cloudflare保护

dev-main 2023-10-17 18:59 UTC

This package is not auto-updated.

Last update: 2024-10-02 22:00:15 UTC


README

logo

Guzzle Cloudflare Bypass

latest release

PayPal donation Buy me a coffee Become a Patron

(此产品在免费和宽松的许可下可用,但需要财务支持以维持其持续改进。除了维护和稳定性外,还有许多期望添加的功能。)

绕过Cloudflare DDoS保护 - 请谨慎使用

此包基于KyranRana的cloudflare-bypass

安装

使用composer

composer require jaymoulin/guzzlehttp-cloudflare

用法

$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!!