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

com.saucesubfresh.starter.crawler.parser.BaseElementSelector Maven / Gradle / Ivy

package com.saucesubfresh.starter.crawler.parser;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;

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

/**
 * @author lijunping on 2022/4/18
 */
public abstract class BaseElementSelector implements ElementSelector{

    @Override
    public String select(String text) {
        if (text != null) {
            return select(Jsoup.parse(text));
        }
        return null;
    }

    @Override
    public List selectList(String text) {
        if (text != null) {
            return selectList(Jsoup.parse(text));
        } else {
            return new ArrayList();
        }
    }

    protected Element selectElement(String text) {
        if (text != null) {
            return selectElement(Jsoup.parse(text));
        }
        return null;
    }

    protected List selectElements(String text) {
        if (text != null) {
            return selectElements(Jsoup.parse(text));
        } else {
            return new ArrayList();
        }
    }

    public abstract Element selectElement(Element element);

    public abstract List selectElements(Element element);

    public abstract boolean hasAttribute();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy