|
发表于 2021-9-22 11:06:54
|
显示全部楼层
河北省石家庄市
你这个地址并不是用302来跳转的,我贴一段用来取 302 跳转的
<?php
function get_redirect_url($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36');
$content = curl_exec($ch);
$redirect_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$redirect_url = ($redirect_url == $url) ? $url : $redirect_url;
curl_close($ch);
return $redirect_url;
}
echo (get_redirect_url('https://www.baidu.com/aaaaaa.php'));
?>
打印的就是 http://www.baidu.com/forbiddenip/forbidden.html 跳到这里来了
|
评分
-
参与人数 1 | 荣誉 +1 |
收起
理由
|
兔子君
| + 1 |
热心帮助他人,荣誉+1,希望继续努力(*^__^*) 嘻嘻! |
查看全部评分
|