HTML4J

码农软件 · 软件分类 · HTML解析器 · 2019-04-03 07:11:23

软件介绍

HTML4J 是一个 Java 解析 HTML 的类库。示例代码:

    Reader re = ...
    // Create the document
    HTMLDoc doc = new HTMLDoc();
    // Load its content
    doc.load(re);
    // Get the HTML
    HTMLFragment html = doc.getHTML();
    // Create a 'date' meta-tag
    HTMLTag tag = HTMLTag.parse("<meta name=\"date\" content=21/01/2001>");
    // Insert it just before the title
    html.insertBefore(html.findTagByName("title"), tag);
    // Create a paragraph
    tag = HTMLTag.create("p");
    // Insert '<p>Paragraph</p>' just before a tag with id="someid"
    html.insertBefore(html.getIdFinder("someid").getTag().getPosition(),
    	tag.toString("Paragraph"));
    // Create an anchor to foo.html
    HTMLTag anchor = HTMLTag.parse("<a href=\"foo.html\">");
    // We could also do a 'HTMLTag.create("a")' and then set the 'href'
    // attribute using getAttributes().setAttribute("href", "foo.html")
    //
    // Now we get a tag block with id="otherid"
    tag = html.getIdFinder("otherid").getTagBlock();
    // Replace the tag that has id="otherid" by the same tag
    // embraced by the foo.html anchor
    html.replace(tag.getBlockPosition(), anchor.toString(tag));
    // For example, if the 'otherid' tag was 'img src="something.jpg"',
    // then the result would be:
    //   '<a target="_blank"  rel="nofollow" href="foo.html"><img id="otherid" src="something.jpg"></a>'
    //
    tag = html.getTagByName("meta");
    // We just got the first 'meta' tag found in the document, and now we
    // set its name attribute to 'last_update', and its value
    // (the 'content' attribute) to "20/01/2001"
    tag.getAttributes().setAttribute("name", "last_update");
    tag.getAttributes().setAttribute("content", "20/01/2001");
    // Commit the changes to the 'meta' tag to the document
    html.update(tag);

本文地址:https://www.codercto.com/soft/d/2744.html

暗网

暗网

杰米·巴特利特 / 刘丹丹 / 北京时代华文书局 / 2018-7 / 59.00

全面深入揭秘“黑暗版淘宝”暗网的幕后世界和操纵者 现实中所有的罪恶,在暗网中,都是明码标价的商品。 暗杀、色情、恋童癖、比特币犯罪、毒品交易…… TED演讲、谷歌特邀专家、英国智库网络专家杰米•巴特利特代表作! 1、 被大家戏称为“黑暗版淘宝”的暗网究竟是什么?微信猎奇 文不能告诉你的真相都在这里了! 2、 因章莹颖一案、Facebook信息泄露危机而被国人所知的暗网......一起来看看 《暗网》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具