new sample
parent
f21097421b
commit
5d2bd925c2
@ -0,0 +1,33 @@
|
||||
package us.codecraft.webmagic.model.samples;
|
||||
|
||||
import us.codecraft.webmagic.Site;
|
||||
import us.codecraft.webmagic.model.ConsolePageModelPipeline;
|
||||
import us.codecraft.webmagic.model.OOSpider;
|
||||
import us.codecraft.webmagic.model.annotation.ExtractBy;
|
||||
import us.codecraft.webmagic.model.annotation.ExtractByUrl;
|
||||
import us.codecraft.webmagic.model.annotation.HelpUrl;
|
||||
import us.codecraft.webmagic.model.annotation.TargetUrl;
|
||||
|
||||
/**
|
||||
* @author code4crafter@gmail.com <br>
|
||||
* Date: 13-8-11 <br>
|
||||
* Time: 下午9:29 <br>
|
||||
*/
|
||||
@TargetUrl("http://www.36kr.com/p/\\d+.html")
|
||||
@HelpUrl("http://www.36kr.com/#/page/\\d+")
|
||||
public class Kr36NewsModel {
|
||||
|
||||
@ExtractBy("//h1[@class='entry-title sep10']")
|
||||
private String title;
|
||||
|
||||
@ExtractBy("//div[@class='mainContent sep-10']")
|
||||
private String content;
|
||||
|
||||
@ExtractByUrl
|
||||
private String url;
|
||||
|
||||
public static void main(String[] args) {
|
||||
OOSpider.create(Site.me().addStartUrl("http://www.36kr.com/"), new ConsolePageModelPipeline(),
|
||||
Kr36NewsModel.class).run();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue