douleng3463 2017-06-22 10:16
浏览 149

从重定向获取链接

I have json. It's consider information about merchants exactly id, link. But this link go to redirect. Like this:

http:\/\/partners.webmasterplan.com\/click.asp?ref=593856&site=5051&type=banner&tnb=1

I need to view all this links and link which will be last in the chain of redirection i should save. What is better way to make it? Technology, or...? Can you give me some advice? Thx!

I found code can it help me?

<?php
$url="http://libero-news.it.feedsportal.com/c/34068/f/618095/s/2e34796f/l/0L0Sliberoquotidiano0Bit0Cnews0C12735670CI0Esaggi0Eper0Ele0Eriforme0Ecostituzionali0EChiaccherano0Ee0Eascoltano0Bhtml/story01.htm";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
print_r($a);echo"<br>";
if(preg_match('#Location: (.*)#', $a, $r)){
 $l = trim($r[1]);
 echo $l;
 }else echo "not working";
 ?>
  • 写回答

1条回答 默认 最新

  • dp20011 2017-06-22 10:51
    关注

    This pages sends no Location header. To be sure of this, know that this header is always accompanied with a HTTP redirection code (3xx). Here you have a code 200.

    With a JavaScript-disabled browser I haven’t been redirected. This strongly hints at a JavaScript redirection. Unfortunately there is no simple way to detect that, as the page’s JS code is minified, and would require heavy work for a PHP script to analyze it.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错