PHP 多卷曲 - 找出特定卷曲句柄使用了什么代理

发布于 2024-09-28 13:18:06 字数 295 浏览 1 评论 0原文

我将多重卷曲与匿名代理一起使用,并且我想在返回卷曲句柄后根据性能和位置等标记代理。我尝试过curl_getinfo(),但它不会返回有关用于该curl 句柄的代理的信息。

有什么想法吗?我考虑过一种可能的方法来识别特定句柄并将其与所使用的代理一起存储,然后当句柄触发并通过curl_multi_info_read()返回时,我可以通过代理查找句柄。但不确定使用什么作为标识符。进行转储将句柄显示为资源(20),但不确定这是否是我可以依赖的东西?

我想如果有像 getOpt() 这样的东西会是理想的,但从我所做的研究中我没有看到类似的卷曲手柄。

I'm using multi curl with anonymous proxies, and I want to flag the proxies based on performance and location etc after the curl handle is returned. I've tried curl_getinfo() but that does not return information about the proxy used for that curl handle.

Any ideas? I've thought about maybe a way to identify a particular handle and storing that with the proxy used, then when the handle has fired off and returned via curl_multi_info_read() I can look up the handle via the proxy. Not sure what to use as an identifier though. Doing a dump shows the handle as resource(20), but not sure if that is something I can rely on?

I guess if there was something like getOpt() would be ideal, but i don't see anything like that for a curl handle from the research I have done.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-柠檬树下少年和吉他 2024-10-05 13:18:06

检查 MultiRequest 库的最新版本。在那里你可以做这样的事情:

$request = new MultiRequest_Request($url);
$request->setCurlOption(CURLOPT_PROXY, $proxy);
// ...
$curlOptions = $request->getCurlOptions();
list($proxyIp, $proxyPort) = explode(':', $curlOptions[CURLOPT_PROXY]);

Check last version of MultiRequest library. There you can do something like this:

$request = new MultiRequest_Request($url);
$request->setCurlOption(CURLOPT_PROXY, $proxy);
// ...
$curlOptions = $request->getCurlOptions();
list($proxyIp, $proxyPort) = explode(':', $curlOptions[CURLOPT_PROXY]);
合久必婚 2024-10-05 13:18:06

我发现了一个并行的curl类(由Pete Warden编写),它使用以下方法传递多curl的数据。

    $this->outstanding_requests[$ch] = array(
        'url' => $url,
        'callback' => $callback,
        'user_data' => $user_data,
        'proxy' => $proxy
    );

当多curl完成时,它能够使用curl句柄通过未完成的请求数组来保存信息。如果您对多卷曲感兴趣,请查看该课程,它为您设置了一切,并且非常可定制。

I found a parallel curl class (by Pete Warden), that passes data for multi-curl using the following..

    $this->outstanding_requests[$ch] = array(
        'url' => $url,
        'callback' => $callback,
        'user_data' => $user_data,
        'proxy' => $proxy
    );

When the multi-curl is done, it's able to use the curl handle to hold information via the outstanding requests array. If you're interested in multi-curl check out the class, it sets up everything for you and is very customizable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文