且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

音悦台800多万MV视频抓取

更新时间:2021-10-04 04:59:19

    闲的蛋疼,抓下音悦台的MV玩玩,昨晚研究到凌晨1点,现把代码分享与此,以作备忘,如果有涉及侵权,请音悦台通知我,我马上删除代码,哈哈!!!音悦台800多万MV视频抓取
       

Java代码  音悦台800多万MV视频抓取
  1. //因为我发现音悦台的MV ID都是7位数字  
  2.         int max = 9999999;  
  3.         for(int i=0; i < max; i++) {  
  4.             String videoId = i + "";  
  5.             String html = HttpClientUtils.getHTML("http://www.yinyuetai.com/insite/get-video-info?flex=true&videoId=" + videoId);  
  6.             //System.out.println(html);  
  7.             if(html == null || "".equals(html) || html.indexOf("找不到编号为") >= 0) {  
  8.                 System.out.println("没有id={" + videoId + "}这个MV");  
  9.                 continue;  
  10.             }  
  11.               
  12.           //音悦台VIP专享MV  
  13.             Pattern pattern = Pattern.compile(".+(http://sh.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.mp4\\?(?!http).*?&vst=0Y).+");  
  14.             Matcher matcher = pattern.matcher(html);  
  15.             if(matcher.find()) {  
  16.                 String url = matcher.group(1);  
  17.                 System.out.println("id={" + videoId + "}VIP专享MV url:" + url);  
  18.             } else {  
  19.                 //超清MV  
  20.                 pattern = Pattern.compile(".+(http://he.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");  
  21.                 matcher = pattern.matcher(html);  
  22.                 if(matcher.find()) {  
  23.                     String url = matcher.group(1);  
  24.                     System.out.println("id={" + videoId + "}超清MV url:" + url);  
  25.                 } else {  
  26.                     //高清MV  
  27.                     //.+(http://hd.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?[^?]+&vst=0Y).+  
  28.                     pattern = Pattern.compile(".+(http://hd.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");  
  29.                     matcher = pattern.matcher(html);  
  30.                     if(matcher.find()) {  
  31.                         String url = matcher.group(1);  
  32.                         System.out.println("id={" + videoId + "}高清MV url:" + url);  
  33.                     } else {  
  34.                         //流畅MV  
  35.                         //.+(http://hc.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?[^?]+&vst=0Y).+  
  36.                         pattern = Pattern.compile(".+(http://hc.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");  
  37.                         matcher = pattern.matcher(html);  
  38.                         if(matcher.find()) {  
  39.                             String url = matcher.group(1);  
  40.                             System.out.println("id={" + videoId + "}流畅MV url:" + url);  
  41.                         } else {  
  42.                             continue;  
  43.                         }  
  44.                     }  
  45.                 }  
  46.             }  
  47.               
  48.         }  

   得到了MV视频的URL后,你可以先把URL全部写到一个txt文件里,然后就写个程序一行一行的读取URL去下载flv文件即可啦,这个大家我想都会吧,就跟下载jpg图片类似的,我就不多啰嗦了!!!效果图如下:
音悦台800多万MV视频抓取
 

转载:http://iamyida.iteye.com/blog/2250181