本文整理了Java中org.jsoup.parser.Tag.getName()
方法的一些代码示例,展示了Tag.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.getName()
方法的具体详情如下:
包路径:org.jsoup.parser.Tag
类名称:Tag
方法名:getName
[英]Get this tag's name.
[中]记下这个标签的名字。
代码示例来源:origin: org.jsoup/jsoup
/**
* Get the name of the tag for this element. E.g. {@code div}
*
* @return the tag name
*/
public String tagName() {
return tag.getName();
}
代码示例来源:origin: org.jsoup/jsoup
@Override
public String nodeName() {
return tag.getName();
}
代码示例来源:origin: org.jsoup/jsoup
private static void appendWhitespaceIfBr(Element element, StringBuilder accum) {
if (element.tag.getName().equals("br") && !TextNode.lastCharIsWhitespace(accum))
accum.append(" ");
}
代码示例来源:origin: org.jsoup/jsoup
public void head(Node node, int depth) {
if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
appendNormalisedText(accum, textNode);
} else if (node instanceof Element) {
Element element = (Element) node;
if (accum.length() > 0 &&
(element.isBlock() || element.tag.getName().equals("br")) &&
!TextNode.lastCharIsWhitespace(accum))
accum.append(' ');
}
}
代码示例来源:origin: com.atlassian.mail/atlassian-mail
private BodyElement(Element body) {
this.body = checkNotNull(body, "Body can not be null");
checkArgument(body.tag().getName().equals("body"), "Element must be the body");
}
代码示例来源:origin: com.soulgalore/crawler
private Set<PageURL> fetch(String query, String attributeKey, Document doc, String url) {
final Set<PageURL> urls = new HashSet<PageURL>();
final Elements elements = doc.select(query);
for (Element src : elements) {
if (src.attr(attributeKey).isEmpty()) continue;
// don't fetch mailto links
if (src.attr(attributeKey).startsWith(MAIL_TO))
continue;
else if (IFRAME.equals(src.tag().getName()))
urls.add(new PageURL(src.attr(attributeKey), url));
else
urls.add(new PageURL(src.attr(attributeKey), url));
}
return urls;
}
}
代码示例来源:origin: soulgalore/crawler
private Set<CrawlerURL> fetch(String query, String attributeKey, Document doc, String url) {
final Set<CrawlerURL> urls = new HashSet<CrawlerURL>();
final Elements elements = doc.select(query);
for (Element src : elements) {
if (src.attr(attributeKey).isEmpty()) continue;
// don't fetch mailto links
if (src.attr(attributeKey).startsWith(MAIL_TO))
continue;
else if (IFRAME.equals(src.tag().getName()))
urls.add(new CrawlerURL(src.attr(attributeKey), url));
else
urls.add(new CrawlerURL(src.attr(attributeKey), url));
}
return urls;
}
}
代码示例来源:origin: br.com.objectos/sitebricks
return false;
if (closingOptional.contains(parent.getName()) && parent.getName().equals(child.getName()))
return false;
if (parent.getName().equals("head")) {
if (headTags.contains(child.getName()))
return true;
else
if (parent.getName().equals("dt") && child.getName().equals("dd"))
return false;
if (parent.getName().equals("dd") && child.getName().equals("dt"))
return false;
代码示例来源:origin: com.google.sitebricks/sitebricks
return false;
if (closingOptional.contains(parent.getName()) && parent.getName().equals(child.getName()))
return false;
if (parent.getName().equals("head")) {
if (headTags.contains(child.getName()))
return true;
else
if (parent.getName().equals("dt") && child.getName().equals("dd"))
return false;
if (parent.getName().equals("dd") && child.getName().equals("dt"))
return false;
代码示例来源:origin: GistLabs/mechanize
private static void filterElementsByTag(List<Element> results, Element element, Set<String> tagSet) {
if(tagSet.contains(element.tag().getName().toLowerCase()))
results.add(element);
for(Element child : element.children())
filterElementsByTag(results, child, tagSet);
}
代码示例来源:origin: dhanji/sitebricks
return false;
if (closingOptional.contains(parent.getName()) && parent.getName().equals(child.getName()))
return false;
if (parent.getName().equals("head")) {
if (headTags.contains(child.getName()))
return true;
else
if (parent.getName().equals("dt") && child.getName().equals("dd"))
return false;
if (parent.getName().equals("dd") && child.getName().equals("dt"))
return false;
代码示例来源:origin: UKPLab/argument-reasoning-comprehension-task
if ("br".equals(element.tag().getName())) {
sb.append("\n");
else if ("a".equals(element.tag().getName())) {
代码示例来源:origin: DigitalPebble/storm-crawler
public void head(Node node, int depth) {
if (excluded == null && node instanceof TextNode) {
TextNode textNode = (TextNode) node;
appendNormalisedText(accum, textNode);
} else if (node instanceof Element) {
Element element = (Element) node;
if (excludedTags.contains(element.tagName())) {
excluded = element;
}
if (accum.length() > 0
&& (element.isBlock() || element.tag().getName()
.equals("br"))
&& !lastCharIsWhitespace(accum))
accum.append(' ');
}
}
代码示例来源:origin: basis-technology-corp/Java-readability
private void handleDoubleBr() {
Elements doubleBrs = document.select("br + br");
for (Element br : doubleBrs) {
// we hope that there's a 'p' up there....
Elements parents = br.parents();
Element parent = null;
for (Element aparent : parents) {
if (aparent.tag().getName().equals("p")) {
parent = aparent;
break;
}
}
if (parent == null) {
parent = br.parent();
parent.wrap("<p></p>");
}
// now it's safe to make the change.
String inner = parent.html();
inner = Patterns.REPLACE_BRS.matcher(inner).replaceAll("</p><p>");
parent.html(inner);
}
}
代码示例来源:origin: ukwa/webarchive-discovery
if( !"#root".equals(e.tag().getName()) && ELEMENT_NAME.matcher(e.tag().getName()).matches() ) {
de.add(StringUtils.left(e.tag().getName().toLowerCase(Locale.ENGLISH), 100));
代码示例来源:origin: pnikosis/jHTML2Md
private static void processElement(Element element, ArrayList<MDLine> lines) {
Tag tag = element.tag();
String tagName = tag.getName();
if (tagName.equals("div")) {
div(element, lines);
代码示例来源:origin: dhanji/sitebricks
private List<Node> parse() {
while (!tq.isEmpty()) {
if (tq.matches("<!--")) {
parseComment();
} else if (tq.matches("<![CDATA[")) {
parseCdata();
} else if (tq.matches("<?") || tq.matches("<!")) {
parseXmlDecl();
} else if (tq.matches("</")) {
parseEndTag();
} else if (tq.matches("<") && !isRawDataTag(stack.peek())) {
parseStartTag();
} else {
parseTextNode();
}
}
// Pop off body as it is already inside html.
Iterator<Node> iterator = stack.iterator();
while (iterator.hasNext()) {
if (iterator.next().nodeName().equals(bodyTag.getName())) {
iterator.remove();
}
}
return stack;
}
代码示例来源:origin: persado/stevia
if (e.tag().isFormSubmittable() || e.tag().getName().equals("a") || e.tag().getName().equals("button")) {
代码示例来源:origin: com.google.sitebricks/sitebricks
private List<Node> parse() {
while (!tq.isEmpty()) {
if (tq.matches("<!--")) {
parseComment();
} else if (tq.matches("<![CDATA[")) {
parseCdata();
} else if (tq.matches("<?") || tq.matches("<!")) {
parseXmlDecl();
} else if (tq.matches("</")) {
parseEndTag();
} else if (tq.matches("<") && !isRawDataTag(stack.peek())) {
parseStartTag();
} else {
parseTextNode();
}
}
// Pop off body as it is already inside html.
Iterator<Node> iterator = stack.iterator();
while (iterator.hasNext()) {
if (iterator.next().nodeName().equals(bodyTag.getName())) {
iterator.remove();
}
}
return stack;
}
代码示例来源:origin: br.com.objectos/sitebricks
private List<Node> parse() {
while (!tq.isEmpty()) {
if (tq.matches("<!--")) {
parseComment();
} else if (tq.matches("<![CDATA[")) {
parseCdata();
} else if (tq.matches("<?") || tq.matches("<!")) {
parseXmlDecl();
} else if (tq.matches("</")) {
parseEndTag();
} else if (tq.matches("<")) {
parseStartTag();
} else {
parseTextNode();
}
}
// Pop off body as it is already inside html.
Iterator<Node> iterator = stack.iterator();
while (iterator.hasNext()) {
if (iterator.next().nodeName().equals(bodyTag.getName())) {
iterator.remove();
}
}
return stack;
}
内容来源于网络,如有侵权,请联系作者删除!