支持以下网址:优酷、土豆、酷6、6间房、新浪、搜狐、56(我乐)、凤凰视频播放页面的解析,解析出来的属性包括:视频标题、视频缩略图、视频简介、视频时长、视频来源、视频页面地址、视频FLASH地址、页面嵌入HTML代码。以后会继续更新支持更多的视频网站,附件中VideoExtract-1.0.jar为引入包,VideoExtract-sources-1.0.jar为源码包。
版本更新说明:
1、2011-09-12 创建版本,支持优酷、土豆、酷6、6间房、新浪、搜狐、56(我乐)视频播放页面的信息解析
2、2011-09-13 新加对凤凰视频的支持,链接地址不在支持的列表中时返回原链接地址以及链接的页面标题
?
使用方法如下:
1、视频对象类org.osm.video.Video.java
package org.osm.video; import java.io.Serializable; public class Video implements Serializable { private static final long serialVersionUID = -6220973207083491817L; private String title = "";// 视频标题 private String thumbnail = "";// 视频缩略图 private String summary = "";// 视频简介 private String time = "";// 视频时长 private String source = "";// 视频来源 private String pageUrl = "";// 视频页面地址 private String flashUrl = "";// 视频FLASH地址 private String htmlCode = "";// 视频HTML代码 public String getTitle() { if (null == title) { return ""; } else { return title; } } public void setTitle(String title) { this.title = title; } public String getThumbnail() { if (null == thumbnail) { return ""; } else { return thumbnail; } } public void setThumbnail(String thumbnail) { this.thumbnail = thumbnail; } public String getSummary() { if (null == summary) { return ""; } else { return summary; } } public void setSummary(String summary) { this.summary = summary; } public String getTime() { if (null == time) { return ""; } else { return time; } } public void setTime(String time) { this.time = time; } public String getSource() { if (null == source) { return ""; } else { return source; } } public void setSource(String source) { this.source = source; } public String getPageUrl() { if (null == pageUrl) { return ""; } else { return pageUrl; } } public void setPageUrl(String pageUrl) { this.pageUrl = pageUrl; } public String getFlashUrl() { if (null == flashUrl) { return ""; } else { return flashUrl; } } public void setFlashUrl(String flashUrl) { this.flashUrl = flashUrl; } public String getHtmlCode() { if (null == htmlCode) { return ""; } else { return htmlCode; } } public void setHtmlCode(String htmlCode) { this.htmlCode = htmlCode; } }
?
2、测试类代码
?
String url = "http://v.youku.com/v_show/id_XMzAyMjE1Nzgw.html"; // String url = "http://www.tudou.com/programs/view/Zkazx5iaUSQ/"; // String url = "http://v.ku6.com/special/show_4024167/Dwq_4xKT5Go4f4F6.html"; // String url = "http://v.ku6.com/show/bFx2VCEiF15U53E6.html"; // String url = "http://6.cn/watch/14757577.html"; // String url = "http://www.56.com/u37/v_NjE3OTQ4NTg.html"; // String url = "http://video.sina.com.cn/p/news/s/v/2011-09-11/133861482545.html"; // String url = "http://tv.sohu.com/20110912/n319076906.shtml"; // String url = "http://v.ifeng.com/documentary/discovery/201109/ed52d159-a3f4-4969-972d-c9e6d51d00ff.shtml"; // String url = "http://www.baidu.com/"; Video video = VideoUtil.getVideoInfo(url); System.out.println("视频标题:" + video.getTitle()); System.out.println("视频地址:" + video.getFlashUrl()); System.out.println("视频时长:" + video.getTime()); System.out.println("视频来源:" + video.getSource()); System.out.println("视频简介:" + video.getSummary()); System.out.println("视频缩略图:" + video.getThumbnail()); System.out.println("视频原始地址:" + video.getPageUrl()); System.out.println("视频网页代码:" + video.getHtmlCode());?