V1.01:
1、提高創建索引的效率
2、通過對象池管理IndexWriter和IndexReader對象
3、修正若干BUG
V1.0:
初始版本
基于Lucene的全文檢索框架,提供快速方便的索引創建及查詢方式,并提供擴展功能對框架進行擴展。
項目地址:http://code.google.com/p/snoics-retrieval/
環境要求
Java1.5+
Lucene 3.0+
做了一些小的修改和調整
基于Lucene的全文檢索框架,提供快速方便的索引創建及查詢方式,并提供擴展功能對框架進行擴展。
項目地址:http://code.google.com/p/snoics-retrieval/
環境要求
Java1.5+
Lucene 3.0+
一個cron表達式有至少6個(也可能7個)有空格分隔的時間元素。
按順序依次為
秒(0~59)
分鐘(0~59)
小時(0~23)
天(月)(0~31,但是你需要考慮你月的天數)
月(0~11)
天(星期)(1~7 1=SUN 或 SUN,MON,TUE,WED,THU,FRI,SAT)
7.年份(1970-2099)
其中每個元素可以是一個值(如6),一個連續區間(9-12),一個間隔時間(8-18/4)(/表示每隔4小時),一個列表(1,3,5),通配符。由于"月份中的日期"和"星期中的日期"這兩個元素互斥的,必須要對其中一個設置?.
0 0 10,14,16 * * ? 每天上午10點,下午2點,4點
0 0/30 9-17 * * ? 朝九晚五工作時間內每半小時
0 0 12 ? * WED 表示每個星期三中午12點
"0 0 12 * * ?" 每天中午12點觸發
"0 15 10 ? * *" 每天上午10:15觸發
"0 15 10 * * ?" 每天上午10:15觸發
"0 15 10 * * ? *" 每天上午10:15觸發
"0 15 10 * * ? 2005" 2005年的每天上午10:15觸發
"0 * 14 * * ?" 在每天下午2點到下午2:59期間的每1分鐘觸發
"0 0/5 14 * * ?" 在每天下午2點到下午2:55期間的每5分鐘觸發
"0 0/5 14,18 * * ?" 在每天下午2點到2:55期間和下午6點到6:55期間的每5分鐘觸發
"0 0-5 14 * * ?" 在每天下午2點到下午2:05期間的每1分鐘觸發
"0 10,44 14 ? 3 WED" 每年三月的星期三的下午2:10和2:44觸發
"0 15 10 ? * MON-FRI" 周一至周五的上午10:15觸發
"0 15 10 15 * ?" 每月15日上午10:15觸發
"0 15 10 L * ?" 每月最后一日的上午10:15觸發
"0 15 10 ? * 6L" 每月的最后一個星期五上午10:15觸發
"0 15 10 ? * 6L 2002-2005" 2002年至2005年的每月的最后一個星期五上午10:15觸發
"0 15 10 ? * 6#3" 每月的第三個星期五上午10:15觸發
有些子表達式能包含一些范圍或列表
例如:子表達式(天(星期))可以為 “MON-FRI”,“MON,WED,FRI”,“MON-WED,SAT”
“*”字符代表所有可能的值
因此,“*”在子表達式(月)里表示每個月的含義,“*”在子表達式(天(星期))表示星期的每一天
“/”字符用來指定數值的增量
例如:在子表達式(分鐘)里的“0/15”表示從第0分鐘開始,每15分鐘
在子表達式(分鐘)里的“3/20”表示從第3分鐘開始,每20分鐘(它和“3,23,43”)的含義一樣
“?”字符僅被用于天(月)和天(星期)兩個子表達式,表示不指定值
當2個子表達式其中之一被指定了值以后,為了避免沖突,需要將另一個子表達式的值設為“?”
“L” 字符僅被用于天(月)和天(星期)兩個子表達式,它是單詞“last”的縮寫
但是它在兩個子表達式里的含義是不同的。
在天(月)子表達式中,“L”表示一個月的最后一天
在天(星期)自表達式中,“L”表示一個星期的最后一天,也就是SAT
如果在“L”前有具體的內容,它就具有其他的含義了
例如:“6L”表示這個月的倒數第6天,“FRIL”表示這個月的最一個星期五
注意:在使用“L”參數時,不要指定列表或范圍,因為這會導致問題
字段 允許值 允許的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小時 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可選) 留空, 1970-2099 , - * /
版本歷史 | |
2.1: | 1、不用再配置snoics-configpath.xml中的路徑。 2、定時自動保存Cache 3、修改了一些Bug |
2.0: | 核心代碼全部重寫,增加了擴展性,通過擴展之后,基本上能實現對整個網站完整的解析 |
1.0: | 實現了整站抓取的基本的功能,不能解析特殊的URL,對javascript無法辨認 |
??? 有些人說不知道snoics-reptile中的snoics-systemconfig.xml不知道怎么配置,這里就給出一個CSDN中Java文檔中心的抓取配置的抓取配置。
???? 在抓取完了之后往Apache的httpd.conf中加入
Listen 10001
<VirtualHost *:10001>
??? DocumentRoot D:\\temp\\reptile\\website
</VirtualHost>
???? 這段配置。
???? 最后刪除抓取下來的文件夾中的D:\temp\reptile\website\author\index.html這個文件。不知道為什么文檔中心的這個URL是一個空的頁面http://dev.csdn.net/author? ,把這個URL的相對應的抓取下的文件刪除就可以正常使用了
???? 在抓取的過程中,有些圖片文件可能會出現錯誤,不過不影響使用,因為這些圖片的路徑本身大概就有些問題。
????? 附件-配置文件:http://www.aygfsteel.com/Files/snoics/snoics-systemconfig.rar
|
|||||||||
|
|||||||||
|
|||||||||
4、如何擴展接口?
|
|||||||||
????擴展接口使用的配置文件是:conf/snoics-reptile-urlregex.xml ????首先加入一段如下的配置 ????<bean id="ahrefRegexUrl" class="com.snoics.reptile.regex.url.impl.UrlRegex" singleton="false"> ????????<property name="regexUrl"> ????????????<!-- 提取可能包含URL的字符串 --> ????????????<value><![CDATA[<[^!<>]*\shref\s*=\s*["']?[^<>]*["'\s][^<>]*>]]></value> ????????</property> ????????<property name="replaceRegexUrl"> ????????????<!-- 替換可能包含URL的字符串 --> ????????????<value><![CDATA[<[^!<>]*\shref\s*=\s*["']?reptile-replace-string["'\s][^<>]*>]]></value> ????????</property> ????????<property name="getRegexUrl"> ????????????<!-- 提取最終URL --> ????????????<ref bean="ahrefGetRegexUrl"/> ????????</property> ????</bean> ???? ????其中ahrefGetRegexUrl是實現了com.snoics.reptile.regex.url.IGetUrlRegex接口的類,用來從可能包含了URL的字符串里面提取其中包含的URL ??? 其次加入如下的配置: ???? <bean id="ahrefGetRegexUrl" class="com.snoics.reptile.regex.url.impl.AhrefGetRegexUrl" singleton="false"> ???????? <property name="regexString"> ????????????? <!-- 提取最終URL --> ?????????????? <value><![CDATA[href\s*=\s*["']?[^\s"]+["'\s]\s*]]></value> ???????? </property> ???????? <property name="unIncludeRegexString"> ??????????????? <!-- ???????????????????? 排除不需要的類型 ???????????????????? 多個正則表達式之間使用';'隔開 ???????????????? ?--> ??????????????? ?<value><![CDATA[javascript\s?:\s?;mailto\s?:\s?;^#$;]]></value> ?????????? </property> ????? </bean> ????最后,在如下的配置中,加入剛才配置好的部分 ????<bean id="urlRegexMap" class="com.snoics.reptile.regex.url.impl.UrlRegexMap"> ????????<property name="ulrRegexMap"> ????????????<map> ????????????????<!-- 名稱 --> ????????????????<entry key="ahref"> ????????????????????<!-- 解析URL使用的類 --> ????????????????????<ref bean="ahrefRegexUrl"/> ????????????????</entry> ????????????????<entry key="src"> ????????????????????<ref bean="srcRegexUrl"/> ????????????????</entry> ????????????</map> ????????</property> ????</bean> |
5、版本歷史 |
|
2.0: |
核心代碼全部重寫,增加了擴展性,通過擴展之后,基本上能實現對整個網站完整的解析 |
1.0: |
實現了整站抓取的基本的功能,不能解析特殊的URL,對javascript無法辨認 |
|
|||||||||
|
|||||||||
|
|||||||||
4、如何擴展接口?
|
|||||||||
????擴展接口使用的配置文件是:conf/snoics-reptile-urlregex.xml ????首先加入一段如下的配置,其中正則表達式部分應該特定的需要自己給出, ??? reptile-replace-string用來代替URL出現的位置,在程序執行的過程中,該部分 ??? 會被自動替換。 ????<bean id="ahrefRegexUrl" class="com.snoics.reptile.regex.url.impl.UrlRegex" singleton="false"> ????????<property name="regexUrl"> ????????????<!-- 提取可能包含URL的字符串 --> ????????????<value><![CDATA[<[^!<>]*\shref\s*=\s*["']?[^<>]*["'\s][^<>]*>]]></value> ????????</property> ????????<property name="replaceRegexUrl"> ????????????<!-- 替換可能包含URL的字符串 --> ????????????<value><![CDATA[<[^!<>]*\shref\s*=\s*["']?reptile-replace-string["'\s][^<>]*>]]></value> ????????</property> ????????<property name="getRegexUrl"> ????????????<!-- 提取最終URL --> ????????????<ref bean="ahrefGetRegexUrl"/> ????????</property> ????</bean> ???? ????其中ahrefGetRegexUrl是實現了com.snoics.reptile.regex.url.IGetUrlRegex ??? 接口的類,用來從可能包含了URL的字符串里面提取其中包含的URL? ??? 其次加入如下的配置: ???? <bean id="ahrefGetRegexUrl" class="com.snoics.reptile.regex.url.impl.AhrefGetRegexUrl" singleton="false"> ???????? <property name="regexString"> ????????????? <!-- 提取最終URL --> ?????????????? <value><![CDATA[href\s*=\s*["']?[^\s"]+["'\s]\s*]]></value> ???????? </property> ???????? <property name="unIncludeRegexString"> ??????????????? <!-- ???????????????????? 排除不需要的類型 ???????????????????? 多個正則表達式之間使用';'隔開 ???????????????? ?--> ??????????????? ?<value><![CDATA[javascript\s?:\s?;mailto\s?:\s?;^#$;]]></value> ?????????? </property> ????? </bean> ????最后,在如下的配置中,加入剛才配置好的部分 ????<bean id="urlRegexMap" class="com.snoics.reptile.regex.url.impl.UrlRegexMap"> ????????<property name="ulrRegexMap"> ????????????<map> ????????????????<!-- 名稱 --> ????????????????<entry key="ahref"> ????????????????????<!-- 解析URL使用的類 --> ????????????????????<ref bean="ahrefRegexUrl"/> ????????????????</entry> ????????????????<entry key="src"> ????????????????????<ref bean="srcRegexUrl"/> ????????????????</entry> ????????????</map> ????????</property> ????</bean> |
5、版本歷史 |
|
2.0: |
核心代碼全部重寫,增加了擴展性,通過擴展之后,基本上能實現對整個網站完整的解析 |
1.0: |
實現了整站抓取的基本的功能,不能解析特殊的URL,對javascript無法辨認 |
/*
* Encrypt 字符串加密
*
* @author shiwei 2004-8-28
*/
package com.snoics.base.util;
/**
* Encrypt 字符串加密
* @author shiwei
*
*/
public class Encrypt {
public Encrypt() {
}
/**
* 加密字符串
* @param encryptstring
* @return String
*/
public static String encrypt(String encryptstring){
String newstring="";
if(encryptstring.length()<1){
return encryptstring;
}else{
String tempstring=StringClass.remove(encryptstring,0,(int)(encryptstring.length()/3));
tempstring=StringClass.getConvertString(tempstring);
encryptstring=StringClass.getConvertString(encryptstring);
newstring=encrypt(encryptstring,tempstring);
return newstring;
}
}
/**
* 普通加密字符串
*
* @param encryptstring1
* @param encryptstring2
* @return String
*/
public static String encrypt(String encryptstring1, String encryptstring2) {
int strcount = 0; //字符串ASCII碼的總和
int newpasswordlength = 0; //生成的密碼長度
int seed1 = 0; //種子
int seed2 = 0;
String str = "";
String newpassword = ""; //生成的密碼
char newchar;
int newcharint = 0;
int thechar = 0;
str = encryptstring2 + encryptstring1;
if (str.length() > 0) {
for (int i = 0; i < str.length(); i++) {
strcount = strcount + str.charAt(i);
}
newpasswordlength = (strcount * strcount) / str.length() + str.length();
int temp = 0;
int temp2 = 0;
while ((newpasswordlength <= 0) || (newpasswordlength > 100)) {
temp = temp + str.length();
temp2 = temp + temp2;
newpasswordlength = 100;
}
for (int i = 0; i < encryptstring1.length(); i++) {
seed1 = seed1 + encryptstring1.charAt(i);
}
for (int i = 0; i < encryptstring2.length(); i++) {
seed2 = seed2 + encryptstring2.charAt(i);
}
for (int i = 0; i < newpasswordlength; i++) {
if (i < str.length()) {
thechar = str.charAt(i);
} else {
thechar = str.charAt(i % (str.length() - 1))
+ str.charAt((str.length() - 1)
- (i % str.length()));
}
newcharint = thechar * (seed1 * (i + 1) + thechar);
newcharint = newString(newcharint);
newcharint = thechar * (seed2 * (i + 1) + thechar);
newcharint = newString(newcharint);
newchar = (char) newcharint;
newpassword = newpassword + String.valueOf(newchar);
}
newpassword = newpassword.substring((encryptstring2.length() + encryptstring1.length()) % 100);
return (newpassword);
} else {
return ("空字符串不能被加密");
}
}
private static int newString(int charint) {
while ((charint > 127) || (charint < 32)) {
while (charint > 127) {
charint = (charint - charint/2+1) / 2;
while(charint==60||charint==62||charint==34||charint==32||charint==39){
charint = charint + 1;
}
}
while (charint < 32) {
charint = (charint + charint/2-1) * 2;
while(charint==60||charint==62||charint==34||charint==32||charint==39){
charint = charint + 1;
}
}
}
return (charint);
}
public static void main(String[] args) {
String theusername = "1abc1";
String thepassword = "1def1";
String theusername1 = "1def1";
String thepassword1 = "1abc1";
String newstring=Encrypt.encrypt(theusername,thepassword);
System.out.println("newstring="+newstring);
String newstringa=Encrypt.encrypt(theusername1,thepassword1);
System.out.println("newstringa="+newstringa);
String newstring2=Encrypt.encrypt(newstring);
System.out.println("newstring2="+newstring2);
String newstring3=Encrypt.encrypt(newstring2);
System.out.println("newstring3="+newstring3);
}
}
執行結果: