GithubHelp home page GithubHelp logo

x-ray-select's Introduction

x-ray select

The selection parser for x-ray. Aiming to bring structure to the web.

Installation

npm install x-ray-select

Features

  • Supports collections and nested collections
  • Supports filters with arguments using format-parser
  • Supports attribute selection

Example

var request = require('superagent');
var assert = require('assert');
var Select = require('x-ray-select');

/**
 * Structure
 */

var struct = [{
  $root: ".item",
  link: 'a@href',
  thumb: 'img@src',
  content: {
    $root: '.item-content',
    title: 'h2',
    body: 'section'
  },
  tags: ['.item-tags li']
}];

/**
 * Fetch the HTML
 */

request.get('http://mat.io', function(err, res) {
  var html = res.text;
  var select = Select(html);
  var arr = select(struct);

  // test
  var item = arr.pop();
  assert.deepEqual(item, {
    "link": "http://ift.tt/1xIsboY",
    "thumb": "http://www.google.com/s2/favicons?domain=http://ift.tt/1xIsboY",
    "content": {
      "title": "The 100 Best Children's Books of All Time",
      "body": "Relive your childhood with TIME's list of the best 100 children's books of all time http://t.co/NEvBhNM4np http://ift.tt/1sk3xdM\n\nโ€” TIME.com (@TIME) January 11, 2015"
    },
    "tags": [
      "twitter"
    ]
  });
});

Test

npm install
make test

License

MIT

x-ray-select's People

Contributors

eheikes avatar matthewmueller avatar olivierlesnicki avatar rsylvian avatar

Stargazers

 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

x-ray-select's Issues

Cannot set property 'filters' of null

Got a crash at --> m.filters = formatters;

I'm using x-ray that use x-ray-select. Not sure why this problem occur ... I've other rules and it's working perfectly fine.

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.