remove duplicated class
parent
c7005a0227
commit
f413450403
|
@ -1,40 +0,0 @@
|
||||||
package us.codecraft.webmagic.model;
|
|
||||||
|
|
||||||
import us.codecraft.webmagic.Page;
|
|
||||||
import us.codecraft.webmagic.Site;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author code4crafter@gmail.com <br>
|
|
||||||
* @date: 13-8-1 <br>
|
|
||||||
* Time: 下午10:18 <br>
|
|
||||||
*/
|
|
||||||
@TargetUrl("http://my.oschina.net/flashsword/blog/*")
|
|
||||||
public class OschinaBlog implements AfterExtractor {
|
|
||||||
|
|
||||||
@ExtractBy("//title")
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
@ExtractBy(value = "div.BlogContent", type = ExtractBy.Type.Css)
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
@ExtractBy(value = "//div[@class='BlogTags']/a/text()", multi = true)
|
|
||||||
private List<String> tags;
|
|
||||||
|
|
||||||
@ExtractBy(value = "//div[@class='BlogTags']/a/text()", multi = true)
|
|
||||||
private List<String> comments;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterProcess(Page page) {
|
|
||||||
System.out.println("title:\t"+title);
|
|
||||||
System.out.println("content:\t"+content);
|
|
||||||
System.out.println("tags:\t" + tags);
|
|
||||||
page.setSkip(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
OOSpider.create(Site.me().addStartUrl("http://my.oschina.net/flashsword/blog/145796"), OschinaBlog.class)
|
|
||||||
.run();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package us.codecraft.webmagic.model;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
import us.codecraft.webmagic.Site;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author code4crafter@gmail.com <br>
|
|
||||||
* @date: 13-8-1 <br>
|
|
||||||
* Time: 下午8:42 <br>
|
|
||||||
*/
|
|
||||||
public class TestFetcher {
|
|
||||||
|
|
||||||
@Ignore("takes long")
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
OOSpider.create(Site.me().addStartUrl("http://my.oschina.net/flashsword/blog/145796"), OschinaBlog.class)
|
|
||||||
.run();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package us.codecraft.webmagic.scheduler;
|
package us.codecraft.webmagic.scheduler;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import us.codecraft.webmagic.Request;
|
import us.codecraft.webmagic.Request;
|
||||||
import us.codecraft.webmagic.Site;
|
import us.codecraft.webmagic.Site;
|
||||||
|
|
Loading…
Reference in New Issue