抖音视频解析

$url = '视频分享链接';
$data = httpGet($url);

$data = strstr($data, 'playAddr');
$data = strstr($data, '&line', 1);
$data = strstr($data, 'https');

$url = str_replace('playwm', 'play', $data);

$arr = get_headers($url, 1);
echo $arr['Location'];

function httpGet($url)
{
	$user_agent = 'Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0';
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
	curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
	curl_setopt($ch, CURLOPT_URL, $url);
	$output = curl_exec($ch);
	curl_close($ch);
	return $output;
}

猜你喜欢

转载自my.oschina.net/qjd/blog/1822002