/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  us.codecraft.webmagic.Page
 *  us.codecraft.webmagic.Site
 *  us.codecraft.webmagic.Spider
 *  us.codecraft.webmagic.processor.PageProcessor
 */
package com.hst.taxService.pageProcessor;

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

public class ZxwjPageProcessor
implements PageProcessor {
    public static final String URL_LIST = "http://www\\.chinatax\\.gov\\.cn/n810341/n810755/index.html";
    public static final String URL_POST = "http://www\\.chinatax\\.gov\\.cn/n810341/n810755/\\w+/content.html";
    private Site site = Site.me().setDomain("chinatax.gov.cn").setSleepTime(30).setUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");

    public void process(Page page) {
        if (page.getUrl().regex(URL_LIST).match()) {
            page.addTargetRequests(page.getHtml().xpath("//dd").links().regex("http://www\\.chinatax\\.gov\\.cn/n810341/n810755/index+//w+.html").all());
        } else {
            page.putField("dw", (Object)page.getHtml().xpath("//li[@class='sv_blue24']/text()"));
            page.putField("title", (Object)page.getHtml().xpath("//li[@class='sv_texth1_red']/text()"));
            page.putField("content", (Object)page.getHtml().xpath("//li[@class='sv_black14_30']/text()").toString().replaceAll("\\s*|\t|\r|\n", ""));
            System.out.println("----" + page.getHtml().xpath("//li[@class='sv_black14_30']/text()").toString());
            page.putField("date", (Object)page.getHtml().xpath("//li[@class='sv_texth3' ]/html()"));
            page.putField("pudate", (Object)page.getHtml().xpath("meta[@name='pubdate']/@content").toString());
        }
    }

    public Site getSite() {
        return this.site;
    }

    public static void main(String[] args) {
        Spider.create((PageProcessor)new ZxwjPageProcessor()).addUrl(new String[]{"http://www.chinatax.gov.cn/n810341/n810755/index.html"}).thread(5).run();
    }
}
