PHP 检测Proxy代理
484 views
0
php 检测socks代理
check_proxy.php
<!-- check proxy socks4 and socks5 Copyright by mimvp.com 2015-02-09 --> <?php define('PROXY_CONF', '124.160.35.2:808'); define('PROXY_CHECK_URL', 'http://www.baidu.com/'); define('PROXY_LOGPATH', dirname(__FILE__) . '/proxy.log'); function check() { $ch = curl_init(); curl_setopt($ch, CURLOPT_PROXY, PROXY_CONF); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); curl_setopt($ch, CURLOPT_URL, PROXY_CHECK_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $response = curl_exec($ch); $error = curl_error($ch); var_dump("<br>response: ".$response); var_dump("<br>eror: ".$error); $tpl = "%s | %s\n"; $time = date('Y-m-d H:i:s'); if(curl_errno($ch)){ @file_put_contents(PROXY_LOGPATH, sprintf($tpl, $time, 'PROXY_NOT_WORKING ERROR:'.curl_error($ch)), FILE_APPEND); } else { @file_put_contents(PROXY_LOGPATH, sprintf($tpl, $time, 'PROXY_IS_WORKING'), FILE_APPEND); } curl_close($ch); unset($ch); } check(); ?>
php 利用socks代理
<?php /* check proxy socks4 and socks5 Copyright by mimvp.com 2015-02-09 */ $curl = curl_init(); curl_setopt($curl, CURLOPT_PROXY, "59.37.163.176:1080"); curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); // 使用SOCKS5, 还有SOCKS4 curl_setopt($curl, CURLOPT_URL, "http://www.mimvp.com"); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); $data = array('user' => "mimvp.com", 'password' => 'mimvp-proxy'); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); //curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1); // 如果是HTTP代理 //curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt'); // cookie你懂的 $request = curl_exec($curl); var_dump("request : ".$request); curl_close($curl); unset($curl) ?>
版权所有: 本文系米扑博客原创、转载、摘录,或修订后发表,最后更新于 2015-02-27 05:58:35
侵权处理: 本个人博客,不盈利,若侵犯了您的作品权,请联系博主删除,莫恶意,索钱财,感谢!
转载注明: PHP 检测Proxy代理 (米扑博客)