some refector
parent
194152ab13
commit
c6132e0746
|
@ -19,17 +19,41 @@ import java.util.Scanner;
|
|||
*/
|
||||
public class QuickStarter {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Map<String, Class> clazzMap = new LinkedHashMap<String, Class>();
|
||||
private static Map<String, Class> clazzMap;
|
||||
|
||||
private static Map<String, String> urlMap;
|
||||
|
||||
private static void init(){
|
||||
clazzMap = new LinkedHashMap<String, Class>();
|
||||
clazzMap.put("1", OschinaBlog.class);
|
||||
clazzMap.put("2", IteyeBlog.class);
|
||||
clazzMap.put("3", News163.class);
|
||||
Map<String, String> urlMap = new LinkedHashMap<String, String>();
|
||||
urlMap = new LinkedHashMap<String, String>();
|
||||
urlMap.put("1", "http://my.oschina.net/flashsword/blog");
|
||||
urlMap.put("2", "http://flashsword20.iteye.com/");
|
||||
urlMap.put("3", "http://news.163.com/");
|
||||
Scanner stdin = new Scanner(System.in);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
init();
|
||||
String key = null;
|
||||
key = readKey(key);
|
||||
System.out.println("The demo started and will last 20 seconds...");
|
||||
//Start spider
|
||||
OOSpider.create(Site.me().addStartUrl(urlMap.get(key)), clazzMap.get(key)).pipeline(new PagedPipeline()).pipeline(new ConsolePipeline()).runAsync();
|
||||
|
||||
try {
|
||||
Thread.sleep(20000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("The demo stopped!");
|
||||
System.out.println("To more usage, try to customize your own Spider!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
private static String readKey(String key) {
|
||||
Scanner stdin = new Scanner(System.in);
|
||||
System.out.println("Choose a Spider demo:");
|
||||
for (Map.Entry<String, Class> classEntry : clazzMap.entrySet()) {
|
||||
System.out.println(classEntry.getKey()+"\t" + classEntry.getValue() + "\t" + urlMap.get(classEntry.getKey()));
|
||||
|
@ -41,19 +65,6 @@ public class QuickStarter {
|
|||
key = null;
|
||||
}
|
||||
}
|
||||
System.out.println("The demo started and will last 20 seconds...");
|
||||
|
||||
//Start spider
|
||||
OOSpider.create(Site.me().addStartUrl(urlMap.get(key)), clazzMap.get(key)).pipeline(new PagedPipeline()).pipeline(new ConsolePipeline()).runAsync();
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(20000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("The demo stopped!");
|
||||
System.out.println("To more usage, try to customize your own Spider!");
|
||||
System.exit(0);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue