我正在尝试从此url ...
获取重定向的网址为此我使用以下代码......
$urlt="http://www.mediaexpert.pl/td_redirect?tduid=cdddb90f50749342ebe92662d5ae2868&url=http://clickserve.dartsearch.net/link/click?lid=43700006682073804&ds_s_kwgid=58700000455306780&ds_url_v=2&ds_dest_url=http%3A%2F%2Fwww.mediaexpert.pl%2Faparaty-kompaktowe%2Faparat-cyfrowy-sony-dsc-hx400vb-czarny,id-220778%3Futm_source%fCAdkEcDcq%26utm_medium%3DXML%26utm_campaign%3D2015-12%0A&utm_medium=linktxt&utm_campaign=2015.11&utm_source=fCAdkEcDcq&utm_content=1831888";
//$url = 'http://www.example.com/product/123/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlt);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Must be set to true so that PHP follows any "Location:" header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ufr = curl_exec($ch); // $a will contain all headers
$urnt = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); // This is what you need, it will return you the last effective URL
echo $urnt;
但它不起作用......虽然这段代码适用于其他网址...我在这里遗漏了什么...请指导我。
答案 0 :(得分:0)
它无效,因为服务器没有使用HTTP
重定向进行响应。
响应正文似乎包含将导致重定向的JavaScript
代码(我没有测试)。但这与libcurl
无关,不会为您运行JavaScript
代码。