zoukankan      html  css  js  c++  java
  • 用PHP获取土豆网视频FLV地址

    主要代码:
    <?php   
    // 根据视频地址取内容   
    $url = "http://www.tudou.com/programs/view/B6q-LhN9e-0/";   
    $txt = file_get_contents($url);   
      
    // 取视频ID   
    preg_match("/var iid = (\d+)/", $txt$match_id);   
    preg_match("/<title>(.*?) - .*<\/title>/", $txt , $match_title);   
    $id = $match_id[1];   
    $title = $match_title[1];   
      
    // 取视频的绝对地址   
    $url = "http://v2.tudou.com/v2/cdn?id={$id}&safekey=YouNeverKnowThat&noCatch=4610";   
    $context = array(   
        'http' => array (   
            'header'=> 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT']   
        )   
    );   
    $xcontext = stream_context_create($context);   
    $txt = file_get_contents($urlfalse$xcontext);   
      
    preg_match_all("/<f.*?>(.*?)<\/f>/", $txt$match);   
    if (is_array($match[1]))   
    {   
        foreach ($match[1] as $k => $v)   
        {   
            $c = $k + 1;   
            echo "下载地址{$c}:<a href=\"$v\">{$title} ($v)</a>  <br />\n";   
        }   
    }   
    ?>  
  • 相关阅读:
    关键字static
    关键字const有什么含义?
    关于目标
    B/B+树的初步理解(一)
    优先队列(priority_queue)
    哨兵的作用
    数学笑话集(一)

    排序算法小结(一)
    KMP算法
  • 原文地址:https://www.cnblogs.com/relax/p/2225224.html
Copyright © 2011-2022 走看看