[英]How can i get html element names from a website url
I want to get HTML element names and attribute names (I don't want to use documet.getElementsByTag("*")
or document.select("*")
) without hard-coding. 我想获得HTML元素名称和属性名称(我不想使用documet.getElementsByTag("*")
或document.select("*")
)而不需要硬编码。
Is there any chance to get HTML element names dynamically by using Apache Tika and, if possible, please provide me any sample example? 有没有机会使用Apache Tika动态获取HTML元素名称,如果可能的话,请提供给我任何示例示例?
Document doc=Jsoup.connect("http://seenyc.co/").get();
Elements elements=doc.getAllElements();
for(Element ele:elements){
String s=ele.tagName();
Attributes n=ele.attributes();
System.out.println(s);
System.out.println(n);
}
HashSet<String> allTags=new HashSet<String>();
Document doc=Jsoup.connect("http://seenyc.co/").get();
Elements elements=doc.getAllElements();
for(Element ele:elements){
String s=ele.tagName();
Attributes n=ele.attributes();
allTags.add(s);
}
// here your hashset will have all distinct tag names from website
Is this what you wanted? 这是你想要的吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.