diff --git a/Readme.md b/Readme.md index 2f7975a7c0..784a08d2d4 100644 --- a/Readme.md +++ b/Readme.md @@ -1,18 +1,35 @@ -# cheerio [![Build Status](https://secure.travis-ci.org/cheeriojs/cheerio.svg?branch=master)](http://travis-ci.org/cheeriojs/cheerio) [![Coverage](http://img.shields.io/coveralls/cheeriojs/cheerio.svg?branch=master&style=flat)](https://coveralls.io/r/cheeriojs/cheerio) [![Join the chat at https://gitter.im/cheeriojs/cheerio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cheeriojs/cheerio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![OpenCollective](https://opencollective.com/cheerio/backers/badge.svg)](#backers) [![OpenCollective](https://opencollective.com/cheerio/sponsors/badge.svg)](#sponsors) +

cheerio

-Fast, flexible, and lean implementation of core jQuery designed specifically for the server. +
Fast, flexible & lean implementation of core jQuery designed specifically for the server.
-## Introduction -Teach your server HTML. +
+ + Travis CI + + + Coverage + + + Join the chat at https://gitter.im/cheeriojs/cheerio + + + OpenCollective backers + + + OpenCollective sponsors + +
+ +
```js -var cheerio = require('cheerio'), - $ = cheerio.load('

Hello world

'); +let cheerio = require('cheerio') +let $ = cheerio.load('

Hello world

') -$('h2.title').text('Hello there!'); -$('h2').addClass('welcome'); +$('h2.title').text('Hello there!') +$('h2').addClass('welcome') -$.html(); +$.html() //=>

Hello there!

``` @@ -29,21 +46,75 @@ Cheerio works with a very simple, consistent DOM model. As a result parsing, man __❁ Incredibly flexible:__ Cheerio wraps around @FB55's forgiving [htmlparser2](https://github.com/fb55/htmlparser2/). Cheerio can parse nearly any HTML or XML document. -## What about JSDOM? -I wrote cheerio because I found myself increasingly frustrated with JSDOM. For me, there were three main sticking points that I kept running into again and again: +## Sponsors -__• JSDOM's built-in parser is too strict:__ - JSDOM's bundled HTML parser cannot handle many popular sites out there today. +Does your company use Cheerio in production? Please consider [sponsoring this project](https://opencollective.com/cheerio#sponsor). Your help will allow maintainers to dedicate more time and resources to its development and support. -__• JSDOM is too slow:__ -Parsing big websites with JSDOM has a noticeable delay. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -__• JSDOM feels too heavy:__ -The goal of JSDOM is to provide an identical DOM environment as what we see in the browser. I never really needed all this, I just wanted a simple, familiar way to do HTML manipulation. +## Backers -## When I would use JSDOM +[Become a backer](https://opencollective.com/cheerio#backer) to show your support for Cheerio and help us maintain and improve this open source project. -Cheerio will not solve all your problems. I would still use JSDOM if I needed to work in a browser-like environment on the server, particularly if I wanted to automate functional tests. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ## API @@ -902,22 +973,27 @@ Cheerio collections are made up of objects that bear some resemblence to [browse - `childNodes` - `lastChild` -## Screencasts +## What about JSDOM? +I wrote cheerio because I found myself increasingly frustrated with JSDOM. For me, there were three main sticking points that I kept running into again and again: -http://vimeo.com/31950192 +__• JSDOM's built-in parser is too strict:__ + JSDOM's bundled HTML parser cannot handle many popular sites out there today. -> This video tutorial is a follow-up to Nettut's "How to Scrape Web Pages with Node.js and jQuery", using cheerio instead of JSDOM + jQuery. This video shows how easy it is to use cheerio and how much faster cheerio is than JSDOM + jQuery. +__• JSDOM is too slow:__ +Parsing big websites with JSDOM has a noticeable delay. -## Testing +__• JSDOM feels too heavy:__ +The goal of JSDOM is to provide an identical DOM environment as what we see in the browser. I never really needed all this, I just wanted a simple, familiar way to do HTML manipulation. -To run the test suite, download the repository, then within the cheerio directory, run: +## When I would use JSDOM -```shell -make setup -make test -``` +Cheerio will not solve all your problems. I would still use JSDOM if I needed to work in a browser-like environment on the server, particularly if I wanted to automate functional tests. -This will download the development packages and run the test suite. +## Screencasts + +http://vimeo.com/31950192 + +> This video tutorial is a follow-up to Nettut's "How to Scrape Web Pages with Node.js and jQuery", using cheerio instead of JSDOM + jQuery. This video shows how easy it is to use cheerio and how much faster cheerio is than JSDOM + jQuery. ## Contributors @@ -988,6 +1064,17 @@ project : cheerio Are you using cheerio in production? Add it to the [wiki](https://github.com/cheeriojs/cheerio/wiki/Cheerio-in-Production)! +## Testing + +To run the test suite, download the repository, then within the cheerio directory, run: + +```shell +make setup +make test +``` + +This will download the development packages and run the test suite. + ## Special Thanks This library stands on the shoulders of some incredible developers. A special thanks to: @@ -1001,95 +1088,6 @@ The core API is the best of its class and despite dealing with all the browser i __• @visionmedia:__ The style, the structure, the open-source"-ness" of this library comes from studying TJ's style and using many of his libraries. This dude consistently pumps out high-quality libraries and has always been more than willing to help or answer questions. You rock TJ. -#### Backers -Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/cheerio#backer)] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#### Sponsors -Become a sponsor and get your logo on our website and on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/cheerio#sponsor)] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## License -(The MIT License) - -Copyright (c) 2012 Matt Mueller <mattmuelle@gmail.com> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +MIT