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

📄 thiefparse9hai.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.DownBatch9HaiThread;
import org.tools.Thief;

public class ThiefParse9Hai extends ThiefParseBase {

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

	public Map<String, String> parse(String homeUrl, String musicPrix, String listUrl) {
	
		//<a href=../play/10282.htm target=_blank'9'>很美的笛子-DS秀</a>

		// 以下取得当前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("<a\\s+href=([^\\s]+)\\s+target=_blank'9'>([^>]+)</a>",Pattern.CASE_INSENSITIVE),
		        p1 = Pattern.compile("<param\\s+name=SRC\\s+value='([^']+)'>",Pattern.CASE_INSENSITIVE);
		
		Matcher m = p.matcher(content),m1;
		while (m.find()) {
			String musicUrl = homeUrl + m.group(1).replaceFirst("\\.\\.","");
			String musicName = m.group(2);
			System.out.println("读取页面"+musicUrl);
			String __content = thief.readURL(musicUrl, null);
			m1 = p1.matcher(__content);
			if(m1.find()){
				map.put(musicName,m1.group(1));
				System.out.println("得到地址:"+musicName+"|"+m1.group(1));
			}
			
		}
		return map;
	}

	
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		ThiefParse9Hai t = new ThiefParse9Hai();
		t.parse("http://www.9hai.com", "http://rm1.9hai.com/", "http://www.9hai.com/Art/5_1.htm");
	}
}

⌨️ 快捷键说明

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