Package webmagic

Source Code of webmagic.App

package webmagic;

import java.util.ArrayList;
import java.util.List;

import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.example.AppStore;
import us.codecraft.webmagic.example.BaiduBaike;
import us.codecraft.webmagic.model.OOSpider;
import us.codecraft.webmagic.processor.example.OschinaBlogPageProcessor;

public class App {

  public static void main(String[] args) {
      
     /*OOSpider ooSpider = OOSpider.create(Site.me().setSleepTime(0), BaiduBaike.class);
          //single download
          String urlTemplate = "http://baike.baidu.com/search/word?word=%s&pic=1&sug=1&enc=utf8";
          //BaiduBaike baike = ooSpider.<BaiduBaike>get("http://baike.baidu.com/search/word?word=httpclient&pic=1&sug=1&enc=utf8");
          //System.out.println(baike);

          //multidownload
          List<String> list = new ArrayList<String>();
          list.add(String.format(urlTemplate,"java"));
          list.add(String.format(urlTemplate,"Html"));
          list.add(String.format(urlTemplate,"jquery"));
          list.add(String.format(urlTemplate,"Spider"));
          System.out.println(list);
          List<BaiduBaike> resultItemses = ooSpider.<BaiduBaike>getAll(list);
          for (BaiduBaike resultItemse : resultItemses) {
              System.out.println(resultItemse);
          }
          ooSpider.close();*/
         
         
          Spider.create(new OschinaBlogPageProcessor()).addUrl("http://my.oschina.net/flashsword/blog").run();
    }
}
TOP

Related Classes of webmagic.App

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.