采集$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,请帖详细代码

解决方案 »

  1.   

    curl_setopt($content,CURLOPT_HEADER,true);
    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);
      

  2.   

    sorry,弄错了,用这个
    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);
      

  3.   

    sorry,我的失误。可我改完了以后抓百度还是全部给抓过来了,只是在顶部有一些网页的基本信息,万恶的csdn不让上传本地图片,值能贴文字的了:HTTP/1.1 200 OK Date: Fri, 07 Sep 2012 07:02:45 GMT Server: BWS/1.0 Content-Length: 9321 Content-Type: text/html;charset=gbk Cache-Control: private Expires: Fri, 07 Sep 2012 07:02:45 GMT Set-Cookie: BAIDUID=3BF5AA016EF302EBBC0BCA27F79A6D88:FG=1; expires=Fri, 07-Sep-42 07:02:45 GMT; path=/; domain=.baidu.com P3P: CP=" OTI DSP COR IVA OUR IND COM " Connection: Keep-Alive这是我的程序:
    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);
      

  4.   


    跳转后的地址还是没有得到http://item.taobao.com/item.htm?id=15711538808&ali_trackid=2:mm_32165125_0_0:1347002474_3k3_1929734884
      

  5.   

    麻烦用我给的淘宝地址测试
    http://s.click.taobao.com/t_8?e=7HZ6jHSTbIWZXoQ43%2BGOC2vGvlT28S6knArdy2HkZM%2BsVw%3D%3D&p=mm_32165125_0_0
      

  6.   

    点击后生成相应的url 这个你得开发一个客户端工具来操作而不是curl
      

  7.   

    curl可以抓取到跳转的url,关键点在于:
    $status = curl_getinfo($ch);
    $status['redirect_url'] ;// 跳转到的新地址