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

WBOY
Release: 2016-06-13 11:48:02
Original
1090 people have browsed it

求个地址获取的代码详细请见帖子
比如土豆的视频地址为: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';<br />$ch = curl_init($url);<br />curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br />curl_setopt($ch, CURLOPT_HEADER, true);<br />curl_exec($ch);<br /><br />$response = curl_exec($ch);<br /><br />preg_match_all('/^Location:(.*)$/mi', $response, $matches);<br />curl_close($ch);<br /><br />echo !empty($matches[1]) ? trim($matches[1][0]) : 'No redirect found';
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template