Home >php教程 >php手册 >php 获取跳转的Url真实地址

php 获取跳转的Url真实地址

WBOY
WBOYOriginal
2016-06-06 19:38:031973browse

有些页面地址加密需要抓取到他跳转的真是地址这个方法还是不错的。 www.ziqing.cc紫青小说网 标记一下! 无 function curl_post_302($url,$data=null) {$ch = curl_init();curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_URL, $url);

有些页面地址加密 需要抓取到他跳转的真是地址 这个方法还是不错的。

www.ziqing.cc 紫青小说网

标记一下!
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;
		}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn