提取视频网站

http://liuguihua0823.iteye.com/blog/1170436

支持以下网址:优酷、土豆、酷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

Java代码 
1.package org.osm.video;  
2. 
3.import java.io.Serializable;  
4. 
5.public class Video implements Serializable {  
6. 
7.    private static final long serialVersionUID = -6220973207083491817L;  
8. 
9.    private String title = "";// 视频标题  
10. 
11.    private String thumbnail = "";// 视频缩略图  
12. 
13.    private String summary = "";// 视频简介  
14. 
15.    private String time = "";// 视频时长  
16. 
17.    private String source = "";// 视频来源  
18. 
19.    private String pageUrl = "";// 视频页面地址  
20. 
21.    private String flashUrl = "";// 视频FLASH地址  
22. 
23.    private String htmlCode = "";// 视频HTML代码  
24. 
25.    public String getTitle() {  
26.        if (null == title) {  
27.            return "";  
28.        } else {  
29.            return title;  
30.        }  
31.    }  
32. 
33.    public void setTitle(String title) {  
34.        this.title = title;  
35.    }  
36. 
37.    public String getThumbnail() {  
38.        if (null == thumbnail) {  
39.            return "";  
40.        } else {  
41.            return thumbnail;  
42.        }  
43.    }  
44. 
45.    public void setThumbnail(String thumbnail) {  
46.        this.thumbnail = thumbnail;  
47.    }  
48. 
49.    public String getSummary() {  
50.        if (null == summary) {  
51.            return "";  
52.        } else {  
53.            return summary;  
54.        }  
55.    }  
56. 
57.    public void setSummary(String summary) {  
58.        this.summary = summary;  
59.    }  
60. 
61.    public String getTime() {  
62.        if (null == time) {  
63.            return "";  
64.        } else {  
65.            return time;  
66.        }  
67.    }  
68. 
69.    public void setTime(String time) {  
70.        this.time = time;  
71.    }  
72. 
73.    public String getSource() {  
74.        if (null == source) {  
75.            return "";  
76.        } else {  
77.            return source;  
78.        }  
79.    }  
80. 
81.    public void setSource(String source) {  
82.        this.source = source;  
83.    }  
84. 
85.    public String getPageUrl() {  
86.        if (null == pageUrl) {  
87.            return "";  
88.        } else {  
89.            return pageUrl;  
90.        }  
91.    }  
92. 
93.    public void setPageUrl(String pageUrl) {  
94.        this.pageUrl = pageUrl;  
95.    }  
96. 
97.    public String getFlashUrl() {  
98.        if (null == flashUrl) {  
99.            return "";  
100.        } else {  
101.            return flashUrl;  
102.        }  
103.    }  
104. 
105.    public void setFlashUrl(String flashUrl) {  
106.        this.flashUrl = flashUrl;  
107.    }  
108. 
109.    public String getHtmlCode() {  
110.        if (null == htmlCode) {  
111.            return "";  
112.        } else {  
113.            return htmlCode;  
114.        }  
115.    }  
116. 
117.    public void setHtmlCode(String htmlCode) {  
118.        this.htmlCode = htmlCode;  
119.    }  
120. 
121.} 
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、测试类代码



Java代码 
1.String url = "http://v.youku.com/v_show/id_XMzAyMjE1Nzgw.html";  
2.// String url = "http://www.tudou.com/programs/view/Zkazx5iaUSQ/";  
3.// String url = "http://v.ku6.com/special/show_4024167/Dwq_4xKT5Go4f4F6.html";  
4.// String url = "http://v.ku6.com/show/bFx2VCEiF15U53E6.html";  
5.// String url = "http://6.cn/watch/14757577.html";  
6.// String url = "http://www.56.com/u37/v_NjE3OTQ4NTg.html";  
7.// String url = "http://video.sina.com.cn/p/news/s/v/2011-09-11/133861482545.html";  
8.// String url = "http://tv.sohu.com/20110912/n319076906.shtml";  
9.// String url = "http://v.ifeng.com/documentary/discovery/201109/ed52d159-a3f4-4969-972d-c9e6d51d00ff.shtml";  
10.// String url = "http://www.baidu.com/";  
11.Video video = VideoUtil.getVideoInfo(url);  
12.System.out.println("视频标题:" + video.getTitle());  
13.System.out.println("视频地址:" + video.getFlashUrl());  
14.System.out.println("视频时长:" + video.getTime());  
15.System.out.println("视频来源:" + video.getSource());  
16.System.out.println("视频简介:" + video.getSummary());  
17.System.out.println("视频缩略图:" + video.getThumbnail());  
18.System.out.println("视频原始地址:" + video.getPageUrl());  
19.System.out.println("视频网页代码:" + video.getHtmlCode()); 
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()); 
VideoExtract-1.0.jar (301 KB)
下载次数: 92
VideoExtract-sources-1.0.jar (107.7 KB)
下载次数: 82
VideoExtract-1.1.zip (378.6 KB)
下载次数: 10

你可能感兴趣的:(网站)