Search in sources :

Example 1 with OOSpider

use of us.codecraft.webmagic.model.OOSpider in project webmagic by code4craft.

the class BaiduBaike method main.

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, "风力发电"));
    list.add(String.format(urlTemplate, "太阳能"));
    list.add(String.format(urlTemplate, "地热发电"));
    list.add(String.format(urlTemplate, "地热发电"));
    List<BaiduBaike> resultItemses = ooSpider.<BaiduBaike>getAll(list);
    for (BaiduBaike resultItemse : resultItemses) {
        System.out.println(resultItemse);
    }
    ooSpider.close();
}
Also used : OOSpider(us.codecraft.webmagic.model.OOSpider) ArrayList(java.util.ArrayList)

Example 2 with OOSpider

use of us.codecraft.webmagic.model.OOSpider in project webmagic by code4craft.

the class BaiduNews method main.

public static void main(String[] args) {
    OOSpider ooSpider = OOSpider.create(Site.me().setSleepTime(0), BaiduNews.class);
    //single download
    BaiduNews baike = ooSpider.<BaiduNews>get("http://news.baidu.com/ns?tn=news&cl=2&rn=20&ct=1&fr=bks0000&ie=utf-8&word=httpclient");
    System.out.println(baike);
    ooSpider.close();
}
Also used : OOSpider(us.codecraft.webmagic.model.OOSpider)

Aggregations

OOSpider (us.codecraft.webmagic.model.OOSpider)2 ArrayList (java.util.ArrayList)1