Commit 3fe3d8f0 authored by yihua.huang's avatar yihua.huang

update

parent 901d6fde
package us.codecraft.webmagic.annotation;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;
/**
* @author yihua.huang@dianping.com <br>
* @date: 13-8-2 <br>
* Time: 上午10:47 <br>
*/
public class ObjectPipeline implements Pipeline {
@Override
public void process(ResultItems resultItems, Task task) {
}
public <T> T read() {
return null;
}
}
...@@ -14,11 +14,4 @@ public class OschinaBlog { ...@@ -14,11 +14,4 @@ public class OschinaBlog {
@ExtractBy(value = "div.BlogContent",type = ExtractBy.Type.Css) @ExtractBy(value = "div.BlogContent",type = ExtractBy.Type.Css)
private String content; private String content;
@Override
public String toString() {
return "OschinaBlog{" +
"title='" + title + '\'' +
", content='" + content + '\'' +
'}';
}
} }
...@@ -15,7 +15,13 @@ public class TestFetcher { ...@@ -15,7 +15,13 @@ public class TestFetcher {
@Ignore("takes long") @Ignore("takes long")
@Test @Test
public void test() { public void test() {
Spider.create(ObjectPageProcessor.create(Site.me().addStartUrl("http://my.oschina.net/flashsword/blog/145796"), OschinaBlog.class)).run(); ObjectPipeline objectPipeline = new ObjectPipeline();
Spider.create(ObjectPageProcessor.create(Site.me().addStartUrl("http://my.oschina.net/flashsword/blog/145796"), OschinaBlog.class))
.pipeline(objectPipeline).runAsync();
OschinaBlog oschinaBlog = null;
while ((oschinaBlog = objectPipeline.read()) != null) {
System.out.println(oschinaBlog);
}
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment