首页 > 解决方案 > 如何使用 cloudflare-bypass?

问题描述

我想使用

Cloudflare 绕过。

我正在使用https://github.com/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( '/tmp' ),
]; // 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!!

错误:-

Fatal error: Uncaught Error: Class 'CloudflareBypass\Storage' not found in

有谁知道我该如何正确使用它?

另外,我可以在 Cloudflare-bypass 中使用 cookie 吗?

标签: guzzlecloudflare

解决方案


缓存是可选的,请尝试使用$aOptions = [];


推荐阅读