局域网内的网络爬虫实现 本人正在做一个局域网内搜索引擎,请问局域网内的爬虫怎么做呢?用java实现,看了个heritrix,好像这个是web爬虫。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 heritrix是个现成的爬行器,拿来下不就可啦修改下那个robott.xml的说明俱可从局域网的起始页开始下http://www.xxx.xxx//index.hmtl 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) throw new IllegalArgumentException("Invalid number of threads: " + threads); } public void go(String strURL) throws Exception { // index each entry point URL long start = System.currentTimeMillis(); for (int i = 0; i < threads; i++) { Thread t = new Thread(this, "Spide " + (i+1)); t.start(); threadList.add(t); } while (threadList.size() >; 0) { Thread child = (Thread)threadList.remove(0); child.join(); } long elapsed = System.currentTimeMillis() - start; } public void run() { String url; try { while ((url = dequeueURL()) != null) { indexURL(url); } }catch(Exception e) { logger.info(e.getMessage()); } } //检测URL列表容器中有没有URL没有被解析,如果有则返回URL由线程继续执行文章出处:http://www.diybl.com/course/webjsh/osgl/200798/71185.html 1楼robott.xml怎么改呢,我才刚开始呢,什么都还不会着了,还望在开发的过程中多指教,谢谢!我是想用lucene做一个局域网的搜索引擎,应该怎么下手呢,现在只知道应该分几部分,如搜索器,索引器,检索器,用户接口等,可是具体每一部分该怎么做呢?要求能检索到局域网中的网页呀,文本文件,word,excel,powerpoint,pdf等文件! 局域网网络爬虫的url是采用什么协议? 我想知道这两个代码哪个更好些,请指教。 静态成员变量能不能被序列化???? 求高手解答!谢谢! 下班前的救命!把日文转成JIS 编码的方法和逆转的方法 为什么明明没有超出heap的界限,却报OutOfMemoryException : java heap space 关于Swing中用按钮做超链接 求两个日期之间相差的天数 数据库是MYSQL 怎样用JAVA语言实现对WORD文档的读写操作? 求助:JAVA SQL程序设计 J2SE调用JS 求一个关于JAVA的排列问题 程序不知道如何写下去……有问题呀……
修改下那个robott.xml的说明俱可
从局域网的起始页开始下
http://www.xxx.xxx//index.hmtl
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)
throw new IllegalArgumentException("Invalid number of threads: " +
threads);
}
public void go(String strURL) throws Exception {
// index each entry point URL
long start = System.currentTimeMillis();
for (int i = 0; i < threads; i++) {
Thread t = new Thread(this, "Spide " + (i+1));
t.start();
threadList.add(t);
}
while (threadList.size() >; 0) {
Thread child = (Thread)threadList.remove(0);
child.join();
}
long elapsed = System.currentTimeMillis() - start;
}
public void run() {
String url;
try {
while ((url = dequeueURL()) != null) {
indexURL(url);
}
}catch(Exception e) {
logger.info(e.getMessage());
}
}
//检测URL列表容器中有没有URL没有被解析,如果有则返回URL由线程继续执行文章出处:http://www.diybl.com/course/webjsh/osgl/200798/71185.html
1楼robott.xml怎么改呢,我才刚开始呢,什么都还不会着了,还望在开发的过程中多指教,谢谢!
我是想用lucene做一个局域网的搜索引擎,应该怎么下手呢,现在只知道应该分几部分,如搜索器,索引器,检索器,用户接口等,可是具体每一部分该怎么做呢?要求能检索到局域网中的网页呀,文本文件,word,excel,powerpoint,pdf等文件!