public class Spider implements Runnable
{
private ArrayList urls; //URL列表
private HashMap indexedURLs; //已经检索过的URL列表
private int threads ; //初始化线程数
public static void main(String argv[]) throws Exception
{
if(argv[0] == null)
{
System.out.println("Missing required argument: [Sit URL]");
return ;
}
Spider Spider = new Spider(argv[0]);
Spider.go();
}
public Spider(String strURL)
{
urls = new ArrayList();
threads = 10;
urls.add(strURL);
threadList = new ArrayList();
indexedURLs = new HashMap();
if (urls.size() == 0)
throw new IllegalArgumentException("Missing required argument: -u [start url]");
if (threads < 1)
("Invalid number of threads: " +
threads);
}
public void go(String strURL) throws Exception
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载