From 21f81bb8c1b46c9da6b614c4f3a018893a044b3e Mon Sep 17 00:00:00 2001 From: Qiannan Lu Date: Fri, 18 Sep 2015 08:59:40 +0800 Subject: [PATCH] update deprecated method --- .../main/java/us/codecraft/webmagic/main/QuickStarter.java | 4 ++-- .../src/test/java/us/codecraft/webmagic/SpiderTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webmagic-samples/src/main/java/us/codecraft/webmagic/main/QuickStarter.java b/webmagic-samples/src/main/java/us/codecraft/webmagic/main/QuickStarter.java index 074dd0f4..61083d69 100644 --- a/webmagic-samples/src/main/java/us/codecraft/webmagic/main/QuickStarter.java +++ b/webmagic-samples/src/main/java/us/codecraft/webmagic/main/QuickStarter.java @@ -38,7 +38,7 @@ public class QuickStarter { 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 MultiPagePipeline()).pipeline(new ConsolePipeline()).runAsync(); + OOSpider.create(Site.me(), clazzMap.get(key)).addUrl(urlMap.get(key)).addPipeline(new MultiPagePipeline()).addPipeline(new ConsolePipeline()).runAsync(); try { Thread.sleep(20000); @@ -57,7 +57,7 @@ public class QuickStarter { System.out.println(classEntry.getKey()+"\t" + classEntry.getValue() + "\t" + urlMap.get(classEntry.getKey())); } while (key == null) { - key = new String(stdin.nextLine()); + key = stdin.nextLine(); if (clazzMap.get(key) == null) { System.out.println("Invalid choice!"); key = null; diff --git a/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java b/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java index dbfa8154..2fd690dd 100644 --- a/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java +++ b/webmagic-samples/src/test/java/us/codecraft/webmagic/SpiderTest.java @@ -18,7 +18,7 @@ public class SpiderTest { @Ignore @Test public void testSpider() throws InterruptedException { - Spider me = Spider.create(new HuxiuProcessor()).pipeline(new FilePipeline()); + Spider me = Spider.create(new HuxiuProcessor()).addPipeline(new FilePipeline()); me.run(); } @@ -31,7 +31,7 @@ public class SpiderTest { SimplePageProcessor pageProcessor2 = new SimplePageProcessor("http://www.diaoyuweng.com/home.php?mod=space&uid=88304&do=thread&view=me&type=thread&from=space", "http://www.diaoyuweng.com/thread-*-1-1.html"); System.out.println(pageProcessor2.getSite().getCharset()); pageProcessor2.getSite().setSleepTime(500); - Spider.create(pageProcessor2).pipeline(new FilePipeline()).scheduler(new FileCacheQueueScheduler("/data/temp/webmagic/cache/")). + Spider.create(pageProcessor2).addPipeline(new FilePipeline()).scheduler(new FileCacheQueueScheduler("/data/temp/webmagic/cache/")). run();