PHP抓取、分析国内视频网站的视频信息工具类(3)

$retval = self::_cget($link);
        if ($retval) {
            $json = json_decode($retval, true);

$data['img'] = $json['data'][0]['logo'];
            $data['title'] = $json['data'][0]['title'];
            $data['url'] = $url;
            $data['swf'] = "http://player.youku.com/player.php/sid/{$matches[1]}/v.swf";

return $data;
        } else {
            return false;
        }
    }

/**
     * 土豆网
     *
     *
     *
     * ?iid=74909603
     * &iid=74909603/v.swf
     */
    private function _parseTudou($url){
        preg_match("#view/([-\w]+)/#", $url, $matches);

if (empty($matches)) {
            if (strpos($url, "/playlist/") == false) return false;

if(strpos($url, 'iid=') !== false){
                $quarr = explode("iid=", $lowerurl);
                if (empty($quarr[1]))  return false;
            }elseif(preg_match("#p\/l(\d+).#", $lowerurl, $quarr)){
                if (empty($quarr[1])) return false;
            }

$html = self::_fget($url);
            $html = iconv("GB2312", "UTF-8", $html);

preg_match("/lid_code\s=https://www.jb51.net/article/\slcode\s=https://www.jb51.net/article/\s[\'\"]([^\'\"]+)/s", $html, $matches);
            $icode = $matches[1];

preg_match("/iid\s=https://www.jb51.net/article/\s.*?\|\|\s(\d+)/sx", $html, $matches);
            $iid = $matches[1];

preg_match("/listData\s=https://www.jb51.net/article/\s(\[\{.*\}\])/sx", $html, $matches);

            $find = array("/\n/", '/\s/', "/:[^\d\"]\w+[^\,]*,/i", "/(\{|,)(\w+):/");
            $replace = array("", "", ':"",', '\\1"\\2":');
            $str = preg_replace($find, $replace, $matches[1]);
            //var_dump($str);
            $json = json_decode($str);
            //var_dump($json);exit;
            if(is_array($json) || is_object($json) && !empty($json)){
                foreach ($json as $val) {
                    if ($val->iid == $iid) {
                        break;
                    }
                }
            }

$data['img'] = $val->pic;
            $data['title'] = $val->title;
            $data['url'] = $url;
            $data['swf'] = "http://www.tudou.com/l/{$icode}/&iid={$iid}/v.swf";

return $data;
        }

$host = "www.tudou.com";
        $path = "/v/{$matches[1]}/v.swf";

$ret = self::_fsget($path, $host);

if (preg_match("#\nLocation: (.*)\n#", $ret, $mat)) {
            parse_str(parse_url(urldecode($mat[1]), PHP_URL_QUERY));

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/ce64277ed0afb81a970acc7a6a0797f5.html