代理IP的使用

2022-05-25 20:16:22 浏览数 (1)

curl

代码语言:javascript复制
curl http://www.icanhazip.com/
curl -x 127.0.0.1:3128 http://www.icanhazip.com/

socks5

代码语言:javascript复制
curl --socks5 127.0.0.1:3129 http://www.icanhazip.com/

php

代码语言:javascript复制
define(URL, 'http://www.icanhazip.com/');
define(PROXY, '127.0.0.1');
define(PORT, 3128);

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, URL);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_PROXY, PROXY);
curl_setopt($curl, CURLOPT_PROXYPORT, PORT);
//curl_setopt($curl, CURLOPT_PROXYUSERPWD, "代理用户名:代理密码");

curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$tmpInfo = curl_exec($curl);
curl_close($curl);
echo $tmpInfo;

0 人点赞