I want to get number of views, duration and also the rating of the particular video in youtube. Is there any way to get the information of the video by passing the video id through URL?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Youtube Data API.
Basically, you want to fetch a URL like http://gdata.youtube.com/feeds/api/videos/kpcqAm8BOlE
and look at the resulting XML.
回答2:
The article Retrieve Title, Description and Thumbnail of a YouTube Video Using AJAX describes how you can do this via simple JavaScript and/or AJAX. It uses the YouTube Data API but the the code example here is to-the-point so that you don't get lost searching the API documentation.
回答3:
for the rating, you can parse the video url and find:
<button class="master-sprite ratingL ratingL-5.0" title="5.0"></button></div><div id="ratingMessage" ><div id="defaultRatingMessage"><span class="smallText">719 ratings
notice 5.0 and 719 here. 5.0 is the rating and 719 is the number of votes.