自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

通過(guò)Java獲取酷6視頻

開(kāi)發(fā) 后端
通過(guò)JAVA獲取酷6視頻,現(xiàn)在很多社會(huì)網(wǎng)站都有這個(gè)功能,用戶輸入酷6視頻地址后,能找到對(duì)應(yīng)的視頻及視頻的縮略圖,有些社區(qū)網(wǎng)站還能獲取到視頻的時(shí)長(zhǎng)。

通過(guò)JAVA獲取酷6視頻,現(xiàn)在很多社會(huì)網(wǎng)站都有這個(gè)功能,用戶輸入酷6視頻地址后,能找到對(duì)應(yīng)的視頻及視頻的縮略圖,有些社區(qū)網(wǎng)站還能獲取到視頻的時(shí)長(zhǎng)。

比如:新浪微博就有這個(gè)功能,當(dāng)用戶輸入視頻網(wǎng)址后,就能獲取到相應(yīng)的視頻地址及視頻的縮略圖。

查看代碼

 

  1. import java.io.IOException;     
  2. import java.io.UnsupportedEncodingException;     
  3. import java.net.MalformedURLException;     
  4.     
  5. import org.jsoup.Jsoup;     
  6. import org.jsoup.nodes.Document;     
  7. import org.jsoup.nodes.Element;     
  8. import org.jsoup.select.Elements;     
  9.     
  10.     
  11. /**    
  12. * 獲取Ku6視頻    
  13. * @author sunlightcs    
  14. * 2011-3-31    
  15. * http://hi.juziku.com/sunlightcs/    
  16. */    
  17. public class Ku6Test {     
  18.     private static String URL = "http://v.ku6.com/special/show_4027224/XFlByjLKGajkK_o-.html";     
  19.          
  20.     public static void main(String[] args) throws Exception{     
  21.              
  22.         Document doc = getURLContent();     
  23.              
  24.              
  25.         /**    
  26.          * 獲取視頻地址    
  27.          */    
  28.         Element flashEt = doc.getElementById("outSideSwfCode");     
  29.         String flash = flashEt.attr("value");     
  30.         System.out.println("視頻地址:"+flash);     
  31.              
  32.         /**    
  33.          * 獲取視頻縮略圖    
  34.          */    
  35.         Element picEt = doc.getElementById("plVideosList");     
  36.         if(picEt!=null){     
  37.             Elements pics = picEt.getElementsByTag("img");     
  38.             String pic = pics.get(0).attr("src");     
  39.             System.out.println("視頻縮略圖:"+pic);     
  40.                  
  41.             /**    
  42.              * 獲取視頻時(shí)長(zhǎng)    
  43.              */    
  44.             Element timeEt = picEt.select("span.review>cite").first();      
  45.             String time = timeEt.text();     
  46.             System.out.println("視頻時(shí)長(zhǎng):"+time);     
  47.         }else{     
  48.             String pic = doc.getElementsByClass("s_pic").first().text();     
  49.             System.out.println("視頻縮略圖:"+pic);     
  50.         }     
  51.              
  52.     }     
  53.          
  54.     /**    
  55.      * 獲取Ku6網(wǎng)頁(yè)的內(nèi)容    
  56.      */    
  57.     private static Document getURLContent() throws MalformedURLException, IOException, UnsupportedEncodingException {     
  58.         Document doc = Jsoup.connect(URL)     
  59.           .data("query""Java")     
  60.           .userAgent("Mozilla")     
  61.           .cookie("auth""token")     
  62.           .timeout(3000)     
  63.           .post();     
  64.         return doc;     
  65.     }     
  66.     
  67. }    

 

其中要用到一個(gè)JAR包,鏈接地址如下:

http://jsoup.org/packages/jsoup-1.5.2.jar

【編輯推薦】

  1. 在Eclipse中開(kāi)發(fā)struts應(yīng)用程序
  2. 手把手教你在Eclipse中配置開(kāi)發(fā)Struts
  3. Eclipse下開(kāi)發(fā)struts完整解決亂碼問(wèn)題
  4. Struts相關(guān)背景介紹
  5. 使用Easy Struts for Eclipse開(kāi)發(fā)Struts
責(zé)任編輯:金賀 來(lái)源: 聚資庫(kù)
相關(guān)推薦

2013-05-09 09:15:24

大數(shù)據(jù)短視頻酷6

2013-04-09 09:54:15

盛大云

2011-12-13 15:26:36

開(kāi)放平臺(tái)

2011-12-13 14:44:02

360開(kāi)放平臺(tái)

2012-02-20 10:28:03

JBossJava

2010-06-10 11:00:03

酷6網(wǎng)

2019-10-21 10:15:15

聯(lián)想

2009-11-20 09:53:02

酷6員工猝死李善友

2009-12-03 08:55:12

Java EE 6

2015-11-23 17:19:12

中國(guó)外包網(wǎng)

2010-09-26 16:46:05

2009-11-19 09:35:10

猝死酷6

2015-07-20 10:30:20

酷樂(lè)視新Q6

2021-01-19 09:35:36

Python視頻游戲編程語(yǔ)言

2017-07-04 11:05:55

2016-03-14 10:27:02

慧聰網(wǎng)

2013-11-28 17:56:17

Hadoop優(yōu)酷土豆視頻

2023-11-24 12:10:43

AI模型

2021-08-04 12:26:27

微軟Windows 10Windows

2012-11-23 14:27:43

IBMdW
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)