libdominator 1.0.6

A HTML Parser Library


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

#libdominator libdominator is a HTML parser library written in d

#Filter Syntax Expression = TAG[PICK]{ATTRNAME:ATTRVALUE} Multiple expressions can be concatenated with "." to find stuff inside of specific parent nodes.

ItemDescriptionExample
TAGThe Name of the nodea , p , div , *
[PICK](can be ommited) Picks only the n th match. n begins on 1. PICK can be a list or range[1] picks the first match , [1,3] picks the first and third , [1..3] picks the first three matches
{ATTRNAME:ATTRVALUE}The attribute selector{id:myID} , {class:someClass} , {href:(regex)^http://}

#example

const string content = `<div id="div-2-div-1">
        <ol id="ol-1">
          <li id="li-1-ol-1">li-1-ol-1 Inner</li>
          <li id="li-2-ol-1">li-2-ol-1 Inner</li>
          <li id="li-3-ol-1">li-3-ol-1 Inner</li>
        </ol>
      </div>`;
      Dominator dom = new Dominator(content);
      assert( dom.getNodes.length == 5);
      assert( dom.filterDom(DomFilter("ol")).length == 1 );
      assert( dom.filterDom(DomFilter("ol.li")).length == 3 );
      assert( dom.filterDom(DomFilter("ol.li{id:li-3-ol-1}")).length == 1 );
 Dominator dom = new Dominator(readText("dummy.html"));
    auto filter = DomFilter("article");
    assert( dom.filterDom(filter).filterComments().length == 1 );
    assert( dom.filterDom(filter).length == 3 );

    filter = DomFilter("div.*.ol.li");
    assert( dom.filterDom(filter).length == 3 );

    filter = DomFilter("div.ol.li");
    assert( dom.filterDom(filter).length == 6 );

    filter = DomFilter("ol.li");
    assert( dom.filterDom(filter).length == 6 );

    filter = DomFilter(`ol.li{id:(regex)^li-[\d]+}`);
    assert( dom.filterDom(filter).length == 6 );

    filter = DomFilter(`ol{id:ol-1}.li{id:(regex)^li-[\d]+}`);
    assert( dom.filterDom(filter).length == 3 );

Or check out https://github.com/mab-on/dominator

Authors:
  • Martin Brzenska
Dependencies:
none
Versions:
1.1.7 2019-Feb-18
1.1.6 2017-Oct-31
1.1.5 2017-Oct-07
1.1.4 2017-Oct-07
1.1.3 2017-Jan-08
Show all 20 versions
Download Stats:
  • 23 downloads today

  • 52 downloads this week

  • 148 downloads this month

  • 5817 downloads total

Score:
2.1
Short URL:
libdominator.dub.pm