⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thiefparse520music.java

📁 音乐网站下载程序
💻 JAVA
字号:
package org.tools.plugin;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.JFrame;
import javax.swing.JLabel;

import org.tools.DownBatch520MusicThread;
import org.tools.Thief;

public class ThiefParse520Music  extends ThiefParseBase{

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		ThiefParse520Music t = new ThiefParse520Music();
		t.parse("http://www.520music.com", "http://wma.520music.com", "http://www.520music.com/MusicList/520music.com_9124.htm");
	}

	public void doDownload(JFrame frame, Map<String, String> map, JLabel state_label, String saveto) {
		// TODO 自动生成方法存根
		new Thread(new DownBatch520MusicThread(map,saveto,state_label)).start();
	}

	public Map<String, String> parse(String homeUrl, String musicPrix, String listUrl) {
		// 以下取得当前URL文档内容
		Thief thief = new Thief();
		String content = thief.readURL(listUrl, null);
		//content = test1;

		if (content == null || content.equals(""))
			return null;

		//System.out.println(content);
		Map<String, String> map = new HashMap<String, String>();
		
		// 分析内容
		Pattern p = Pattern.compile("type=\"checkbox\"\\s+value=\"(\\d+)\"",Pattern.CASE_INSENSITIVE),
		        p1 = Pattern.compile("param\\s+name=\"filename\"\\s+value=\"([^\"]+)\"",Pattern.CASE_INSENSITIVE),
		        p2 = Pattern.compile("target=_blank''c''>([^\\\\<]+)</a>");
		
		Matcher m = p.matcher(content),m1,m2=p2.matcher(content);
		while (m.find()) {
			String musicUrl = homeUrl +"/play/"+m.group(1)+".htm";
			String musicName = null;
			int index = m.start(1);
			if(m2.find(index))			
				musicName = m2.group(1).replaceAll("&nbsp;", " ");
			System.out.println("读取页面"+musicUrl);
			String __content = thief.readURL(musicUrl, null);
			
			m1 = p1.matcher(__content);
			if(m1.find()&&musicName!=null){
				map.put(musicName,m1.group(1));
				System.out.println("得到地址:"+musicName+"|"+m1.group(1));
			}
			
		}
		return map;
	}

	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -