<?php echo json_encode(TangDou::parse1($url)); class TangDou { public static function parse1($url) { $content = self::curl($url); preg_match("#poster:'(.*?)'#",$content,$images); preg_match("#video:'(.*?)'#",$content,$urls); preg_match("#class=\"title\">(.*?)</div>#",$content,$titles); $videoinfo['code'] = 200; $videoinfo['play'] = 'h5mp4'; $videoinfo['data']['url'] = $urls[1]; $videoinfo['data']['title'] = $titles[1]; $videoinfo['data']['poster'] = $images[1]; return $videoinfo; } public static function parse($url) { $content = self::curl($url); preg_match("#vid\s*=\s*'(\d+)'#",$content,$_vid); preg_match("#videourl\s*=\s*'(\w+)'#",$content,$vurl); $vid = $_vid[1]; if(!emptyempty($vurl[1])){ $hash = $vurl[1]; }else{ preg_match('#vid:\s*"(\w+)"#',$content,$_vurl); if(!emptyempty($_vurl[1])){ $hash = $_vurl[1]; }else{ preg_match('#id="cc_([\w]{32})"#',$content,$cc); if (!emptyempty($cc[1])) { $hash = $cc[1]; } } } return self::get_video_url($vid,$hash); } public static function get_video_url($vid,$hash) { $api = "http://share.tangdou.com/mp4.php?vid={$vid}&videourl={$hash}"; $content = self::curl($api); preg_match('#src=\\\"(.*?)\\\"#',$content,$vurl) $video['code'] = 200; $video["data"]["url"] = $vurl[1]; $video["play"] = "h5mp4"; return $video; } public static function curl($url) { $params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"; return GlobalBase::curl($url,$params); } } ?>
非常棒