guzzle - 如何使用 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 吗?
解决方案
缓存是可选的,请尝试使用$aOptions = [];
。
推荐阅读
- firebase - Firestore 计费和使用 API
- spring-boot - 如何在 thymeleaf 表达式 th:each 中使用 kotlin 表达式?
- swift - AVPlayer seek 后的当前时间不正确
- powershell - 无法使用 powershell export-csv 将错误消息附加到 csv
- exception - system.invalidoperationexception 序列在 system.linq.enumerable.first[TSource]{IEnumaberable`1 source} 处不包含任何元素
- linux - ParaView、Surface pro 6 Linux 中的小图标
- php - CardDAV 从 iCloud 获取所有联系人
- c# - 从字符串中删除点
- firebase - firebase部署功能上的触发功能
- reactjs - 如何模拟输入 onChange 事件,然后模拟点击结果