欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

求个地址获取的代码详细请见帖子解决方案

程序员文章站 2024-01-18 21:12:40
...
求个地址获取的代码详细请见帖子
比如土豆的视频地址为:http://www.tudou.com/a/OpofdZOE_mI/&iid=131686432&resourceId=0_04_05_99/v.swf
直接访问后为:
http://js.tudouui.com/bin/player2/olc_8.swf?iid=131686432&swfPath=http://js.tudouui.com/bin/lingtong/SocialPlayer_79.swf&youkuId=XNjc0MTE5MDky&vcode=XNjc0MTE5MDky&tvcCode=-1&tag=null&title=%E7%AC%AC07%E8%AF%9D+%E8%80%8D%E9%98%B4%E9%99%A9%E2%80%A6%E2%80%A6%21%21&mediaType=vi&totalTime=1434760&hdType=3&hasPassword=0&nWidth=512&isOriginal=0&channelId=9&nHeight=288&banPublic=false&videoOwner=102599789&tict=2&tvcCode=-1&channelId=9&cs=6_480|482&k=&totalTime=1434760&panelRecm=http://css.tudouui.com/bin/lingtong/PanelRecm_9.swz&panelDanmu=http://css.tudouui.com/bin/lingtong/PanelDanmu_1.swz&panelEnd=http://css.tudouui.com/bin/lingtong/PanelEnd_11.swz&pepper=http://css.tudouui.com/bin/binder/pepper_17.png&panelShare=http://css.tudouui.com/bin/lingtong/PanelShare_7.swz&panelCloud=http://css.tudouui.com/bin/lingtong/PanelCloud_8.swz&prd=&autoPlay=false&listType=3&rurl=&resourceId=0_04_05_99&autostart=false&lid=0&aid=228258&aCode=OpofdZOE_mI&code=JH-1K_odtwE&snap_pic=http%3A%2F%2Fr1.ykimg.com%2F054104085301E3696A0A4F52041D537C&aopRate=0.001&p2pRate=0.95&adSourceId=81000&yjuid=1392279724827k3i&yseid=1392887009649TQcVcx&yseidtimeout=1392898462767&yseidcount=4&uid=null&juid=018h4v26uu19ca&vip=0
怎么样用PHP获取访问后的地址并输出
------解决方案--------------------
$url='http://www.tudou.com/a/OpofdZOE_mI/&iid=131686432&resourceId=0_04_05_99/v.swf';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_exec($ch);

$response = curl_exec($ch);

preg_match_all('/^Location:(.*)$/mi', $response, $matches);
curl_close($ch);

echo !empty($matches[1]) ? trim($matches[1][0]) : 'No redirect found';
求个地址获取的代码详细请见帖子解决方案

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频