从 YouTube 视频中获取标题 [英] Get title from YouTube videos
本文介绍了从 YouTube 视频中获取标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提取 YouTube 视频的标题.我该怎么做?
I want to extract the Title of YouTube's videos. How can I do this?
谢谢.
推荐答案
获取有关 youtube 视频 afaik 的信息的最简单方法是解析从以下位置检索的字符串:http://youtube.com/get_video_info?video_id=XXXXXXXX
Easiest way to obtain information about a youtube video afaik is to parse the string retrieved from: http://youtube.com/get_video_info?video_id=XXXXXXXX
使用类似 PHP 的 parse_str(),您可以获得关于视频的几乎所有内容都很好:
Using something like PHP's parse_str(), you can obtain a nice array of nearly anything about the video:
$content = file_get_contents("http://youtube.com/get_video_info?video_id=".$id);
parse_str($content, $ytarr);
echo $ytarr['title'];
这将使用 $id 作为视频的 ID 打印视频的标题.
That will print the title for the video using $id as the video's id.
这篇关于从 YouTube 视频中获取标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文