闲的蛋疼,抓下音悦台的MV玩玩,昨晚研究到凌晨1点,现把代码分享与此,以作备忘,如果有涉及侵权,请音悦台通知我,我马上删除代码,哈哈!!!
- //因为我发现音悦台的MV ID都是7位数字
- int max = 9999999;
- for(int i=0; i < max; i++) {
- String videoId = i + "";
- String html = HttpClientUtils.getHTML("http://www.yinyuetai.com/insite/get-video-info?flex=true&videoId=" + videoId);
- //System.out.println(html);
- if(html == null || "".equals(html) || html.indexOf("找不到编号为") >= 0) {
- System.out.println("没有id={" + videoId + "}这个MV");
- continue;
- }
- //音悦台VIP专享MV
- Pattern pattern = Pattern.compile(".+(http://sh.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.mp4\\?(?!http).*?&vst=0Y).+");
- Matcher matcher = pattern.matcher(html);
- if(matcher.find()) {
- String url = matcher.group(1);
- System.out.println("id={" + videoId + "}VIP专享MV url:" + url);
- } else {
- //超清MV
- pattern = Pattern.compile(".+(http://he.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");
- matcher = pattern.matcher(html);
- if(matcher.find()) {
- String url = matcher.group(1);
- System.out.println("id={" + videoId + "}超清MV url:" + url);
- } else {
- //高清MV
- //.+(http://hd.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?[^?]+&vst=0Y).+
- pattern = Pattern.compile(".+(http://hd.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");
- matcher = pattern.matcher(html);
- if(matcher.find()) {
- String url = matcher.group(1);
- System.out.println("id={" + videoId + "}高清MV url:" + url);
- } else {
- //流畅MV
- //.+(http://hc.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?[^?]+&vst=0Y).+
- pattern = Pattern.compile(".+(http://hc.yinyuetai.com/uploads/videos/common/[a-zA-Z0-9]+\\.flv\\?(?!http).*?&vst=0Y).+");
- matcher = pattern.matcher(html);
- if(matcher.find()) {
- String url = matcher.group(1);
- System.out.println("id={" + videoId + "}流畅MV url:" + url);
- } else {
- continue;
- }
- }
- }
- }
- }
得到了MV视频的URL后,你可以先把URL全部写到一个txt文件里,然后就写个程序一行一行的读取URL去下载flv文件即可啦,这个大家我想都会吧,就跟下载jpg图片类似的,我就不多啰嗦了!!!效果图如下:
转载:http://iamyida.iteye.com/blog/2250181