View Javadoc
1   package us.codecraft.webmagic.model.samples;
2   
3   import us.codecraft.webmagic.Site;
4   import us.codecraft.webmagic.model.annotation.ExtractBy;
5   import us.codecraft.webmagic.model.OOSpider;
6   import us.codecraft.webmagic.model.annotation.TargetUrl;
7   
8   /**
9    * @author code4crafter@gmail.com <br>
10   * Date: 13-8-2 <br>
11   * Time: 上午7:52 <br>
12   */
13  @TargetUrl("http://*.iteye.com/blog/*")
14  public class IteyeBlog implements Blog{
15  
16      @ExtractBy("//title")
17      private String title;
18  
19      @ExtractBy(value = "div#blog_content",type = ExtractBy.Type.Css)
20      private String content;
21  
22      @Override
23      public String toString() {
24          return "IteyeBlog{" +
25                  "title='" + title + '\'' +
26                  ", content='" + content + '\'' +
27                  '}';
28      }
29  
30      public static void main(String[] args) {
31          OOSpider.create(Site.me(), IteyeBlog.class).addUrl("http://flashsword20.iteye.com/blog").run();
32      }
33  
34      public String getTitle() {
35          return title;
36      }
37  
38      public String getContent() {
39          return content;
40      }
41  }