如何获取网页跳转后的真实网址?
- 内容介绍
- 文章标签
- 相关推荐
本文共计83个文字,预计阅读时间需要1分钟。
phpfunction curl_post_302($url, $data=null) { $ch=curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30);}
function curl_post_302($url,$data=null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 获取转向后的内容 $data = curl_exec($ch); $Headers = curl_getinfo($ch); curl_close($ch); if($data != $Headers){ return $Headers["url"]; }else{ return false; } }
本文共计83个文字,预计阅读时间需要1分钟。
phpfunction curl_post_302($url, $data=null) { $ch=curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30);}
function curl_post_302($url,$data=null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 获取转向后的内容 $data = curl_exec($ch); $Headers = curl_getinfo($ch); curl_close($ch); if($data != $Headers){ return $Headers["url"]; }else{ return false; } }

