采集$url="http://s.click.taobao.com/t_8?e=7HZ6jHSTbIWZXoQ43%2BGOC2vGvlT28S6knArdy2HkZM%2BsVw%3D%3D&p=mm_32165125_0_0";
淘宝会自动跳转url地址:http://item.taobao.com/item.htm?id=15711538808&ali_trackid=2:mm_32165125_0_0:1346999816_310_551572511怎样才能获取到跳转后的url,请帖详细代码
淘宝会自动跳转url地址:http://item.taobao.com/item.htm?id=15711538808&ali_trackid=2:mm_32165125_0_0:1346999816_310_551572511怎样才能获取到跳转后的url,请帖详细代码
curl_setopt($content, CURLOPT_NOBODY,true);
curl_setopt($content,CURLOPT_TIMEOUT,3);
curl_setopt($content,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($content,CURLOPT_MAXREDIRS,20);
curl_setopt($content,CURLOPT_RETURNTRANSFER,true);
curl_setopt($content,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.0)");
$orders=@curl_exec($content);
@curl_close($content);
curl_setopt($content,CURLOPT_URL,$rel_url);
curl_setopt($content,CURLOPT_HEADER,0);
curl_setopt($content,CURLOPT_TIMEOUT,50);
curl_setopt($content,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($content,CURLOPT_MAXREDIRS,20);
curl_setopt($content,CURLOPT_RETURNTRANSFER,true);
curl_setopt($content,CURLOPT_USERAGENT,"Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 5.0)");
curl_setopt($content,CURLOPT_REFERER,$rel_url);
curl_setopt($content,CURLOPT_ENCODING,"gzip");
$orders=curl_exec($content);
curl_close($content);
function get_title($url)
{
@$content=curl_init();
curl_setopt($content,CURLOPT_URL,$url);
curl_setopt($content,CURLOPT_HEADER,true);
curl_setopt($content, CURLOPT_NOBODY,false);
curl_setopt($content,CURLOPT_TIMEOUT,3);
curl_setopt($content,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($content,CURLOPT_MAXREDIRS,20);
curl_setopt($content,CURLOPT_RETURNTRANSFER,true);
curl_setopt($content,CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.0)");
$orders=@curl_exec($content);
@curl_close($content);
return $orders;
}
$e=get_title('http://www.baidu.com/');
print_r($e);
跳转后的地址还是没有得到http://item.taobao.com/item.htm?id=15711538808&ali_trackid=2:mm_32165125_0_0:1347002474_3k3_1929734884
http://s.click.taobao.com/t_8?e=7HZ6jHSTbIWZXoQ43%2BGOC2vGvlT28S6knArdy2HkZM%2BsVw%3D%3D&p=mm_32165125_0_0
$status = curl_getinfo($ch);
$status['redirect_url'] ;// 跳转到的新地址