本文整理了Java中org.jsoup.nodes.Document.getElementsByAttribute()
方法的一些代码示例,展示了Document.getElementsByAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.getElementsByAttribute()
方法的具体详情如下:
包路径:org.jsoup.nodes.Document
类名称:Document
方法名:getElementsByAttribute
暂无
代码示例来源:origin: stackoverflow.com
Document doc = Jsoup.connect(URL_TO_HTML_PAGE).get();
Elements newsHeadlines = doc.getElementsByAttribute("value1");
String ip = newsHeadlines[0].text().split("**")[1];
代码示例来源:origin: stackoverflow.com
String partialHtml = "<html><head><meta something=\"something\">";
Document document = Jsoup.parse(partialHtml);
Elements values = document.getElementsByAttribute("something");
for (Element el : values) {
System.out.println(el.attr("something"));
}
代码示例来源:origin: org.kantega.openaksess/openaksess-core
@Override
public Document runFilter(Document document) {
for (String attribute : attributes) {
Elements withHref = document.getElementsByAttribute(attribute);
fixContextPathForAttribute(withHref, attribute);
}
return document;
}
代码示例来源:origin: jenkinsci/email-ext-plugin
/**
* Transfers styles from the <code>cssstyle</code> attribute to the
* <code>style</code> attribute.
*
* @param doc the html document
*/
private void applyStyles(Document doc) {
Elements allStyledElements = doc.getElementsByAttribute(CSS_STYLE);
for (Element e : allStyledElements) {
String newStyle = e.attr(CSS_STYLE);
String oldStyle = e.attr(STYLE_ATTR);
e.attr(STYLE_ATTR, (newStyle + "; " + oldStyle).replace(";;", ";"));
e.removeAttr(CSS_STYLE);
}
}
代码示例来源:origin: fr.sii.ogham/ogham-core
/**
* Transfers styles from the <code>data-cssstyle</code> attribute to the
* <code>style</code> attribute.
*
* @param doc
* the html document
*/
private void applyStyles(Document doc) {
Elements allStyledElements = doc.getElementsByAttribute(TEMP_STYLE_ATTR);
for (Element e : allStyledElements) {
String newStyle = e.attr(TEMP_STYLE_ATTR);
String oldStyle = e.attr(STYLE_ATTR);
e.attr(STYLE_ATTR, (newStyle + "; " + oldStyle).replaceAll(";+", ";").trim());
e.removeAttr(TEMP_STYLE_ATTR);
}
}
代码示例来源:origin: org.kantega.openaksess/openaksess-core
@Override
public Document runFilter(Document document) {
Elements elementsWithAlign = document.getElementsByAttribute("align");
for (Element element : elementsWithAlign) {
String align = element.attr("align");
if ("right".equalsIgnoreCase(align)) {
element.attr("style", "text-align: right;");
} else if ("left".equalsIgnoreCase(align)) {
element.attr("style", "text-align: left;");
} else if ("center".equalsIgnoreCase(align)) {
element.attr("style", "text-align: center;");
}
element.removeAttr("align");
}
return document;
}
}
代码示例来源:origin: stackoverflow.com
public void parseURL(String url) throws IOException {
url = url.toLowerCase();
if (!result.contains(url)) {
Connection connection = Jsoup.connect(url);
Document document = connection.get();
Elements links = document.getElementsByAttribute("href");
// Elements links = document.select("a[href]");
for (Element link : links) {
String href = link.attr("href");
result.add(href);
parseURL(link.absUrl("href"));
currentDepth++;
if (currentDepth == maxDepth)
return;
}
}
}
代码示例来源:origin: de.ruedigermoeller/kontraktor-http
Elements resourcLinks = doc.getElementsByAttribute("src");
for (int i = 0; i < resourcLinks.size(); i++) {
Element element = resourcLinks.get(i);
代码示例来源:origin: org.tinymediamanager.plugins/scraper-kodi
for (Element el : doc.getElementsByAttribute("point")) {
String point = el.attr("point");
if (point.equals("xbmc.addon.metadata")) {
内容来源于网络,如有侵权,请联系作者删除!