Giter VIP home page Giter VIP logo

chital's Introduction

chital Code Climate Build Status npm version Coverage Status Dependency Status

NPM

Scrape web pages for groups of articles

Example of usage

// require the library
var chital = require( 'chital' );

// initialize the scraper with the options for the website
// you want to get news from.
// example for Hacker News
var scraper = chital({
  url : "http://news.ycombinator.com/news",
  type : "text/html",
  selectors : {
    // a CSS selector that gathers every article you want to scrape
    list : "td:not([align]).title",
    // a CSS selector for each property you want to gather from
    // the article listing (relative to the listSelector)
    article : {
      // you can pass an object with keys
      // selector and attr. In this case, it specifies that
      // you want to gather the href attribute from the "a"
      // selector
      url : {
        selector : "a",
        attr : "href"
      },
      // or simply a CSS selector that's relative to the
      // listSelector which you specified before
      src : "span",
      title : "a"
    }
  }
});

// execute the scraping itself
scraper.execute(function( err, items ) {
  if ( err ) {
    return console.log( err );
  }
  // do something with the items array.
  // every item in the array has the properties you
  // passed in the article selector object previously.
  // In this case, this means you'll get an object with
  // properties url, title and src.
});

Some website configurations reside in test/files/sitesToScrape.json

Disclaimer

This is still a work in progress, under active development. At the moment, the library is in alpha stage, providing very basic functionality. If you have any question, feel free to open an issue on this repository.

License

Copyright (c) 2014 António Nuno Monteiro

This work is distributed under the MIT license. For more information refer to the LICENSE file.

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.