use of org.jsoup.select.Elements in project ZhihuDailyPurify by izzyleung.
the class NewsListFromZhihuObservable method getQuestions.
private static List<Question> getQuestions(Document document, String dailyTitle) {
List<Question> result = new ArrayList<>();
Elements questionElements = getQuestionElements(document);
for (Element questionElement : questionElements) {
Question question = new Question();
String questionTitle = getQuestionTitleFromQuestionElement(questionElement);
String questionUrl = getQuestionUrlFromQuestionElement(questionElement);
// Make sure that the question's title is not empty.
questionTitle = TextUtils.isEmpty(questionTitle) ? dailyTitle : questionTitle;
question.setTitle(questionTitle);
question.setUrl(questionUrl);
result.add(question);
}
return result;
}
use of org.jsoup.select.Elements in project opennms by OpenNMS.
the class HttpCollectionHandler method fillCollectionSet.
@Override
protected void fillCollectionSet(String urlString, Request request, CollectionAgent agent, CollectionSetBuilder builder, XmlSource source) throws Exception {
Document doc = getJsoupDocument(urlString, request);
for (XmlGroup group : source.getXmlGroups()) {
LOG.debug("fillCollectionSet: getting resources for XML group {} using selector {}", group.getName(), group.getResourceXpath());
Date timestamp = getTimeStamp(doc, group);
Elements elements = doc.select(group.getResourceXpath());
LOG.debug("fillCollectionSet: {} => {}", group.getResourceXpath(), elements);
String resourceName = getResourceName(elements, group);
LOG.debug("fillCollectionSet: processing XML resource {}", resourceName);
final Resource collectionResource = getCollectionResource(agent, resourceName, group.getResourceType(), timestamp);
LOG.debug("fillCollectionSet: processing resource {}", collectionResource);
for (XmlObject object : group.getXmlObjects()) {
Elements el = elements.select(object.getXpath());
if (el == null) {
LOG.info("No value found for object named '{}'. Skipping.", object.getName());
}
builder.withAttribute(collectionResource, group.getName(), object.getName(), el.html(), object.getDataType());
}
processXmlResource(builder, collectionResource, resourceName, group.getName());
}
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Rgaa32016Rule110102 method putLabelElementHandlerIntoTheMap.
/**
* This method linked each label which have an input child on a page to its
* form in a map.
*/
private void putLabelElementHandlerIntoTheMap() {
for (Element el : labelElementHandler.get()) {
Element tmpElement = el.parent();
while (tmpElement != null && StringUtils.isNotBlank(tmpElement.tagName())) {
if (tmpElement.tagName().equals(FORM_ELEMENT)) {
if (labelFormMap.containsKey(tmpElement)) {
Elements els = el.select(FORM_ELEMENT_WITH_ID_CSS_LIKE_QUERY);
if (!els.isEmpty()) {
labelFormMap.get(tmpElement).add(el);
}
} else {
Elements els = el.select(FORM_ELEMENT_WITH_ID_CSS_LIKE_QUERY);
if (!els.isEmpty()) {
ElementHandler<Element> labelElement = new ElementHandlerImpl();
labelElement.add(el);
labelFormMap.put(tmpElement, labelElement);
}
}
break;
}
tmpElement = tmpElement.parent();
}
}
}
use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.
the class Rgaa32016Rule050201 method select.
@Override
protected void select(SSPHandler sspHandler) {
super.select(sspHandler);
// once tables selected, we extract the caption child element of each
// to make the control
Elements captionOnTable = new Elements();
for (Element el : getSelectionWithoutMarkerHandler().get()) {
captionOnTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithoutMarkerHandler().clean().addAll(captionOnTable);
Elements captionOnDataTable = new Elements();
for (Element el : getSelectionWithMarkerHandler().get()) {
captionOnDataTable.add(el.select(CAPTION_ELEMENT).first());
}
getSelectionWithMarkerHandler().clean().addAll(captionOnDataTable);
}
use of org.jsoup.select.Elements in project AndroidDevelop by 7449.
the class JsoupTool method getDetail.
public DetailModel getDetail(String url) {
Document document = getDocument(url);
DetailModel detailModel = new DetailModel();
if (document == null) {
throw new NullPointerException("the document is null");
}
Elements select = document.select("div.bottem2").select("a[href$=.html]");
for (int i = 0; i < select.size(); i++) {
switch(i) {
case 0:
detailModel.setOnPage(select.get(i).attr("abs:href"));
break;
case 1:
detailModel.setNextPage(select.get(i).attr("abs:href"));
break;
}
}
detailModel.setTitle(document.select("div.bookname").select("h1").text());
detailModel.setContent(document.select("#content").html());
KLog.i(detailModel.getOnPage() + " " + detailModel.getNextPage());
return detailModel;
}
Aggregations