Package org.osm.jsoup.nodes

Examples of org.osm.jsoup.nodes.Document


      } catch (Exception e) {
        video = null;
      }
    } else {
      // 链接地址不在支持的列表中时返回原链接地址以及链接的页面标题
      Document doc = getURLContent(url);
      video = new Video();
      video.setTitle(doc.title());
      video.setPageUrl(url);
    }

    return video;
  }
View Full Code Here


   *
   * @param url
   *            视频URL
   */
  public static Video getYouKuVideo(String url) throws Exception {
    Document doc = getURLContent(url);

    /**
     * 视频标题
     */
    String title = doc.title().split("-")[0].trim();

    /**
     * 获取视频缩略图
     */
    String pic = getElementAttrById(doc, "s_sina", "href");
    int local = pic.indexOf("pic=");
    pic = pic.substring(local + 4);

    /**
     * 获取视频地址
     */
    String flash = getElementAttrById(doc, "link2", "value");

    /**
     * 获取视频网页代码
     */
    String htmlCode = getElementAttrById(doc, "link3", "value");

    /**
     * 获取视频时间
     */
    String time = getElementAttrById(doc, "download", "_href");
    String[] arrays = time.split("\\|");
    time = arrays[4];

    /**
     * 获取视频简介
     */
    String summary = "";
    try {
      Element el = doc.getElementById("long");
      summary = el.select(".item").get(0).html();
    } catch (Exception e) {
    }

    Video video = new Video();
View Full Code Here

   *
   * @param url
   *            视频URL
   */
  public static Video getTudouPlayListVideo(String url) throws Exception {
    Document doc = getURLContent(url);
    String content = doc.html();

    int beginLocal = content.indexOf("<script>var");
    int endLocal = content.indexOf("</script>");
    content = content.substring(beginLocal, endLocal);
   
    String[] playListInfo=url.split("playlist")[1].split("i");
    String id="";
    if(playListInfo.length==1){
      //URL中不带有播放的文件id
       id = getScriptVarByName("defaultIid", content).trim();
       content=content.split(id)[3];
      //System.out.println(id);
    }else{
      //URL带有播放的文件id
       id = playListInfo[1].split("\\.")[0];
       content=content.split(id)[1];
      //System.out.println(id);
    }
   
   
    /**
     * 视频标题
     */
    String title = "";
    try {
      //title:"
      title = content.split("title:\"")[1].split("\"")[0].trim();
    } catch (Exception e) {
    }

    /**
     * 获取视频地址
     */
    String flash = "";
      flash = content.split("icode:\"")[1].split("\"")[0];
      flash = "http://www.tudou.com/v/" + flash.trim() + "/v.swf";
    /**
     * 获取视频缩略图
     */
    String pic = "";
      pic = content.split("pic:\"")[1].split("\"")[0].trim();
      //pic = pic.trim();

    /**
     * 视频简介
     */
    String summary = "";
    try {
      summary = doc.select("meta[name=Description]").attr("content");
    } catch (Exception e) {
    }
    /**
     * 获取视频时间
     */
 
View Full Code Here

   *
   * @param url
   *            视频URL
   */
  public static Video getTudouVideo(String url) throws Exception {
    Document doc = getURLContent(url);
    String content = doc.html();

    int beginLocal = content.indexOf("<script>document.domain");
    int endLocal = content.indexOf("</script>");
    content = content.substring(beginLocal, endLocal);
    /**
     * 视频标题
     */
    String title = "";
    try {
      title = doc.title().split("_")[0].trim();
    } catch (Exception e) {
    }

    /**
     * 获取视频地址
     */
    String flash = "";
      flash = getScriptVarByName("iid_code", content);
      flash = "http://www.tudou.com/v/" + flash.split("=")[1].trim() + "/v.swf";
    /**
     * 获取视频缩略图
     */
    String pic = "";
      pic = getScriptVarByName("thumbnail", content);
      pic = pic.split("=")[1].trim();

    /**
     * 视频简介
     */
    String summary = "";
    try {
      summary = doc.select("meta[name=Description]").attr("content");

    } catch (Exception e) {
    }
    /**
     * 获取视频时间
 
View Full Code Here

   *
   * @param url
   *            视频URL
   */
  public static Video getKu6Video(String url) throws Exception {
    Document doc = getURLContent(url);

    /**
     * 获取视频标题
     */
    String title = doc.title().split(" ")[0].trim();

    /**
     * 获取视频地址
     */
    String flash = getElementAttrById(doc, "outSideSwfCode", "value");

    /**
     * 获取视频地址
     */
    String htmlCode = getElementAttrById(doc, "outSideHtmlCode", "value");

    /**
     * 获取视频缩略图
     */
    Element picEt = doc.getElementById("plVideosList");
    String time = null;
    String pic = null;
    if (picEt != null) {
      Elements pics = picEt.getElementsByTag("img");
      pic = pics.get(0).attr("src");

      /**
       * 获取视频时长
       */
      Element timeEt = picEt.select("span.review>cite").first();
      time = timeEt.text();
    } else {
      pic = doc.getElementsByClass("s_pic").first().text();
    }

    /**
     * 视频简介
     */
    String summary = doc.select("meta[name=Description]").attr("content");

    Video video = new Video();
    video.setTitle(title);
    video.setThumbnail(pic);
    video.setFlashUrl(flash);
View Full Code Here

   *
   * @param url
   *            视频URL
   */
  public static Video get6Video(String url) throws Exception {
    Document doc = getURLContent(url);

    /**
     * 视频标题
     */
    String title = doc.title().split("-")[0].trim();

    /**
     * 获取视频缩略图
     */
    Element picEt = doc.getElementsByClass("summary").first();
    String pic = picEt.getElementsByTag("img").first().attr("src");

    /**
     * 视频简介
     */
    String summary = doc.select("meta[name=Description]").attr("content");

    /**
     * 获取视频地址
     */
    Element flashEt = doc.getElementById("video-share-code");
    doc = Jsoup.parse(flashEt.attr("value"));
    String flash = doc.select("embed").attr("src");

    Video video = new Video();
    video.setTitle(title);
    video.setThumbnail(pic);
    video.setFlashUrl(flash);
View Full Code Here

   *
   * @param url
   *            视频URL
   */
  public static Video get56Video(String url) throws Exception {
    Document doc = getURLContent(url);
    String content = doc.html();

    /**
     * 视频标题
     */
    String title = doc.getElementById("VideoTitle").select("h1").text();

    /**
     * 获取视频缩略图
     */
    int begin = content.indexOf("\"img\":\"");
    content = content.substring(begin + 7, begin + 200);
    int end = content.indexOf("\"};");
    String pic = content.substring(0, end).trim();
    pic = pic.replaceAll("\\\\", "");

    /**
     * 获取视频地址
     */
    String flash = "http://player.56.com" + url.substring(url.lastIndexOf("/"), url.lastIndexOf(".html")) + ".swf";

    /**
     * 视频简介
     */
    String summary = doc.select("meta[name=Description]").attr("content");

    Video video = new Video();
    video.setTitle(title);
    video.setThumbnail(pic);
    video.setFlashUrl(flash);
View Full Code Here

   * @param url
   * @return
   * @throws Exception
   */
  public static Video getSinaVideo(String url) throws Exception {
    Document doc = getURLContent(url);

    /**
     * 视频标题
     */
    String title = doc.getElementById("videoTitle").text();

    /**
     * 视频简介
     */
    String summary = doc.getElementById("videoContent").text();

    String content = doc.html();
    int beginLocal = content.indexOf("document.domain");
    int endLocal = content.indexOf("</script>");
    content = content.substring(beginLocal + 2, endLocal);

    /**
 
View Full Code Here

   * @param url
   * @return
   * @throws Exception
   */
  public static Video getSohuVideo(String url) throws Exception {
    Document doc = getURLContent(url);

    /**
     * 视频标题
     */
    String title = doc.title().split("-")[0].trim();

    /**
     * 视频简介
     */
    String summary = doc.select(".vIntro.clear > p").text();

    /**
     * 视频缩略图
     */
    String thumbnail = doc.getElementById("thumbnail").attr("src");

    String videoId = thumbnail.split("_")[2];

    /**
     * 视频FLASH地址
 
View Full Code Here

   * @param url
   * @return
   * @throws Exception
   */
  public static Video getIfengVideo(String url) throws Exception {
    Document doc = getURLContent(url);
    String content = doc.html();
    int beginLocal = content.indexOf("videoinfo={");
    int endLocal = content.indexOf("</script>");
    content = content.substring(beginLocal, endLocal);
    content = content.replaceAll("\"", "").replaceAll("\n", "").trim();
    content = content.substring(11, content.length() - 2);
    String[] params = content.split(",");

    /**
     * 视频标题
     */
    String title = doc.select(".playtitle > h1").text();

    /**
     * 视频简介
     */
    String summary = doc.getElementById("full_des").text();
    summary = summary.replaceAll("<<收起", "");

    /**
     * 视频FLASH地址
     */
 
View Full Code Here

TOP

Related Classes of org.osm.jsoup.nodes.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.