All Downloads are FREE. Search and download functionalities are using the official Maven repository.

us.codecraft.webmagic.samples.NjuBBSProcessor Maven / Gradle / Ivy

The newest version!
package us.codecraft.webmagic.samples;

import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

import java.util.List;

/**
 * @author [email protected] 
* Date: 13-4-21 * Time: 下午8:08 */ public class NjuBBSProcessor implements PageProcessor { @Override public void process(Page page) { List requests = page.getHtml().regex("]*href=(bbstcon\\?board=Pictures&file=[^>]*)").all(); page.addTargetRequests(requests); page.putField("title",page.getHtml().xpath("//div[@id='content']//h2/a")); page.putField("content",page.getHtml().smartContent()); } @Override public Site getSite() { return Site.me().setDomain("bbs.nju.edu.cn"); } public static void main(String[] args) { Spider.create(new NjuBBSProcessor()).addUrl("http://bbs.nju.edu.cn/board?board=Pictures").run(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy