关于curl批量验证代理的一个问题
curl多线程 代理 验证 proxy curl 多线程 代理 验证
问题是这样的: 我用curl多线程来验证代理....1 |
|
回复讨论(解决方案)
有木有朋友在呀....在线等了10积分争了 貌似还没有回音...
你的 $proxyarr[$linknum] 是如何赋值的?
一般宜做成通过代理访问同一个网站(不知道你是否是这么做的)
这样只要某个 $mh 项能正常返回,就表示对应的代理是正确可用的
CURLOPT_PROXY 设置代理地址和端口
CURLOPT_PROXYUSERPWD 设置代理的用户名和口令
你也可以用
CURLOPT_HTTPPROXYTUNNEL、CURLOPT_PROXYAUTH、CURLOPT_PROXYPORT、CURLOPT_PROXYTYPE
做细节设置
你的 $proxyarr[$linknum] 是如何赋值的?
一般宜做成通过代理访问同一个网站(不知道你是否是这么做的)
这样只要某个 $mh 项能正常返回,就表示对应的代理是正确可用的
CURLOPT_PROXY 设置代理地址和端口
CURLOPT_PROXYUSERPWD 设置代理的用户名和口令
你也可以用
CURLOPT_HTTPPROXYTUNNEL、CURLOPT_PROXYAUTH、CURLOPT_PROXYPORT、CURLOPT_PROXYTYPE
做细节设置 是这样的 有关代理设置,参数设置我都已经做好了..现在就是在逐一获取多线程单一句柄的时候 获取改句柄到底使用的是那个代理 如果这个句柄返回的是200代码 我就可以吧这个代理保存下来.. 现在问题是没办法获取到这个句柄使用的代理
一般宜做成通过代理访问同一个网站(不知道你是否是这么做的)
这样只要某个 $mh 项能正常返回,就表示对应的代理是正确可用的 现在还是如果发现这个代理是可用的 ,,那么应该如何获取这个代理呢 因为是批量验证 所以每个句柄使用的都是不同的代理..网站倒是一样的
木有人在咯...版主大大呢
你的 $proxyarr 不是顺序加入 $mh 的吗?
嗯,你的后两节写的有些古怪
我一般这样写:
$mh = curl_multi_init();
//加入单个的curl
foreach ($urls as $i => $url) {
$conn[$i] = curl_init($url);
curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER,1);
curl_multi_add_handle($mh, $conn[$i]);
}
//等待全部完成
do {
curl_multi_exec($mh, $active);
}while($active);
//处理每个curl的返回
foreach ($urls as $i => $url) {
$info = curl_getinfo($conn[$i]);//这里就是了
curl_close($conn[$i]);
}
$conn 和 $urls 是一一对应的
//处理每个curl的返回
foreach ($urls as $i => $url) {
$info = curl_getinfo($conn[$i]);//这里就是了
curl_close($conn[$i]);
}
$conn 和 $urls 是一一对应的 明白了,, 这样子也是可以的,,其实是做法不一样 我是在多线程并发的时候等待完成的句柄小小一有消息就把好的代理输出来..想这样验证的代理一般都是几千个的.如果用你的做法,可能要把这几千个代理验证完了才能输出好的代理 ,时间太长了..还有一个地方不一样就是 我限制了并发的句柄的数量 只有等一个句柄完成了,才把下一个句柄添加进去..
还有木有人在呀 ,,,版主大大一个人忙不过来额 求各位来帮帮忙...
嗯,我不喜欢纸上谈兵
快与不快要做了才知道
嗯,我不喜欢纸上谈兵
快与不快要做了才知道 现在没有纸上谈兵呀...- - 在解决这个问题我先这么做吧..效果出来再继续问你 可以私信给我你的QQ么
.
通过curl好像没有好的方式,你为什么不在请求的url是多传递一个参数,参数的内容就是$linknum,在获取的时候可以通过获取
$chinfo = curl_getinfo($mhinfo['handle']);
$chinfo['url']肯定就会带有这个$linknum
而你通过$linknum一定知道代理是什么
通过curl好像没有好的方式,你为什么不在请求的url是多传递一个参数,参数的内容就是$linknum,在获取的时候可以通过获取
$chinfo = curl_getinfo($mhinfo['handle']);
$chinfo['url']肯定就会带有这个$linknum
而你通过$linknum一定知道代理是什么 这个随便加一个参数会不会页面验证非法的参数二初二难题呢??
通过curl好像没有好的方式,你为什么不在请求的url是多传递一个参数,参数的内容就是$linknum,在获取的时候可以通过获取
$chinfo = curl_getinfo($mhinfo['handle']);
$chinfo['url']肯定就会带有这个$linknum
而你通过$linknum一定知道代理是什么 不过这也是个好方法...的确可行的..
过程有些波折 不过最后还是解决了 ..谢谢斑竹 还有下面"hnxxwyq"

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

In this article, we're going to explore the notification system in the Laravel web framework. The notification system in Laravel allows you to send notifications to users over different channels. Today, we'll discuss how you can send notifications ov
