update
parent
901d6fde1d
commit
3fe3d8f044
|
@ -0,0 +1,21 @@
|
||||||
|
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 {
|
||||||
@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 {
|
||||||
@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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue