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";   
        }   
    }   
    ?>  
  • 相关阅读:
    awk查看本机IP+查看本网段mac
    wget
    kvm安装,使用,优化
    方向
    bindview+dlz(mysql)
    页面侧滑栏效果
    数据库的事务理解
    页面平衡移动进出的效果
    返回键弹出是否退出对话框
    引导页之页面等待3秒跳转
  • 原文地址:https://www.cnblogs.com/relax/p/2225224.html
Copyright © 2011-2022 走看看