yskl 发表于 2018-2-11 12:06:55


            本文实例为大家分享了检查代理ip有效性php代码,稳定性,如错误率和查询用时
/**
+-----------------------------------------------------------------------------
* 检查代理ip信息有效性
+-----------------------------------------------------------------------------
* @param string $proxy_ip
* @param int $times 执行检查次数
* @return array
* @author elinx2016-07-29
+-----------------------------------------------------------------------------
*/
function check_proxy_ip_info($proxy_ip=false, $times=10) {
$header = array(
    // "GET / HTTP/1.1",
    // "HOST: www.baidu.com",
    "accept: application/json",
    "accept-encoding: gzip, deflate",
    "accept-language: en-US,en;q=0.8",
    "content-type: application/json",
    "user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36",
);
$url = 'http://www.baidu.com/';
$result['succeed_times'] = 0; //成功次数
$result['defeat_times'] = 0; //失败次数
$result['total_spen']= 0; //总用时
for ($i=0; $i
页: [1]
查看完整版本: php代码检查代理ip的有效性