
因为ip被限制,无法正常的访问网站,那么如何利用php做不同虚拟ip访问网站呢?下面web建站小编带大家了解一下!
实现代码如下:
<?php
function doCurl($url, $data=array(), $header=array(), $referer='', $timeout=30){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
// 模拟来源
curl_setopt($ch, CURLOPT_REFERER, $referer);
$response = curl_exec($ch);
if($error=curl_error($ch)){
die($error);
}
curl_close($ch);
return $response;
}
// 调用
$url = 'http://www.example.com/server.php';
$data = array();
// 设置IP
$header = array(
'CLIENT-IP: 192.168.1.100',
'X-FORWARDED-FOR: 192.168.1.100'
);
// 设置来源
$referer = '设置访问网站域名';
$response = doCurl($url, $data, $header, $referer, 5);
echo $response;
?>
上面是“如何利用php做不同虚拟(模拟)ip访问网站”的全面内容,想了解更多关于 php入门 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2740.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

个人seoVS团队seo 哪个更有优势
国资央企招聘平台官网首页入口
v-for循环出现控制Duplicate keys detected: 'XXXXXX'报错是什么原因