Giter VIP home page Giter VIP logo

element-finder's People

Contributors

keeganstreet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

element-finder's Issues

Plain text output format

Overview

Would be great to use Element Finder to select the content of an HTML element based on its CSS path.

Example

For example, consider the following HTML document:

<html>
<body>
  <div class="header">
  <h1>Header</h1>
  </div>
  <div class="content">
    <table>
      <tbody>
      <tr><td class="data">Tabular Content 1</td></tr>
      <tr><td class="data">Tabular Content 2</td></tr>
      </tbody>
    </table>
  </div>
  <div class="footer">
  <p>Footer</p>
  </div>
</body>
</html>

I'd like to execute the following

elfindiner -s "td.data" -t page.html

This would write the following to standard output:

Tabular Content 1
Tabular Content 2

Does not correctly parse self-closing tags

E.g. .a .b will incorrectly find 2 results in the following case:

<div class="a">
    <div class="b">Should match</div>
    <div class="autoclosed" />
</div>
<div class="b">Should not match</div>

Normalize whitespace, eliminate new lines

Another interesting feature would be to normalize whitespace and eliminate new line characters from content. For example:

<td class="data">This   is     a     comment
that a user made.</td>

By normalizing whitespace and eliminating new lines, you could obtain cleaner data:

<td class="data">This is a comment that a user made.</td>

The content of the element can then be extracted:

This is a comment that a user made.

For example:

cat filename.html | elfinder --normalize-whitespace --no-eol --extract-content --selector "td.data"

TypeError in jsdom.js

Hey there,

just tried you nifty little project but got an error in the knee...

/xxx/htdocs/node_modules/jsdom/lib/jsdom.js:250
    window.document.documentElement.appendChild(script);
                                    ^
TypeError: Cannot call method 'appendChild' of null
at exports.env.exports.jsdom.env.processHTML (/xxx/htdocs/node_modules/jsdom/lib/jsdom.js:250:41)
at Array.forEach (native)
at exports.env.exports.jsdom.env.processHTML (/xxx/htdocs/node_modules/jsdom/lib/jsdom.js:233:18)
at Object.exports.env.exports.jsdom.env (/xxx/htdocs/node_modules/jsdom/lib/jsdom.js:262:5)
at processFile (/xxx/htdocs/node_modules/element-finder/element-finder.js:141:10)
at walk.extension (/xxx/htdocs/node_modules/element-finder/element-finder.js:172:5)
at /xxx/htdocs/node_modules/element-finder/element-finder.js:92:10
at /xxx/htdocs/node_modules/element-finder/element-finder.js:92:10
at /xxx/htdocs/node_modules/element-finder/element-finder.js:92:10
at /xxx/htdocs/node_modules/element-finder/element-finder.js:92:10

Raising exception in domtosource 'The html and selector parameters are required''

Simply running the script on a jekyll based project folder, with any selector.

Found 1 match in /master/_site/index.html
/Element Finder/lib/submodule-elfinder/node_modules/domtosource/app.js:73
throw new Error('The html and selector parameters are required');
^

Error: The html and selector parameters are required
at Object.find (/Element Finder/lib/submodule-elfinder/node_modules/domtosource/app.js:73:10)
at processFile (/Element Finder/lib/submodule-elfinder/element-finder.js:179:27)
at walk.extension (/Element Finder/lib/submodule-elfinder/element-finder.js:231:5)
at /Element Finder/lib/submodule-elfinder/element-finder.js:107:10
at /Element Finder/lib/submodule-elfinder/element-finder.js:107:10

Unsure why?

Write test cases with Mocha

Test cases are essential to know that the module runs correctly. These tests will need to be written before we switch over from JSDOM to Cheerio, so that we can be sure that the switch doesn't break Element Finder.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.