<h1 align="center">cheerio</h1>
<h5 align="center">Fast, flexible & lean implementation of core jQuery designed specifically for the server.</h5>
<div align="center">
<a href="http://travis-ci.org/cheeriojs/cheerio">
<img src="https://secure.travis-ci.org/cheeriojs/cheerio.svg?branch=master" alt="Travis CI" />
</a>
<a href="https://coveralls.io/r/cheeriojs/cheerio">
<img src="http://img.shields.io/coveralls/cheeriojs/cheerio.svg?branch=master&style=flat" alt="Coverage" />
</a>
<a href="https://gitter.im/cheeriojs/cheerio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge">
<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/cheeriojs/cheerio" />
</a>
<a href="#backers">
<img src="https://opencollective.com/cheerio/backers/badge.svg" alt="OpenCollective backers"/>
</a>
<a href="#sponsors">
<img src="https://opencollective.com/cheerio/sponsors/badge.svg" alt="OpenCollective sponsors"/>
</a>
</div>
<br />
```js
const cheerio = require('cheerio')
const $ = cheerio.load('<h2 class="title">Hello world</h2>')
$('h2.title').text('Hello there!')
$('h2').addClass('welcome')
$.html()
//=> <html><head></head><body><h2 class="title welcome">Hello there!</h2></body></html>
```
## Installation
`npm install cheerio`
## Features
__❤ Familiar syntax:__
Cheerio implements a subset of core jQuery. Cheerio removes all the DOM inconsistencies and browser cruft from the jQuery library, revealing its truly gorgeous API.
__ϟ Blazingly fast:__
Cheerio works with a very simple, consistent DOM model. As a result parsing, manipulating, and rendering are incredibly efficient. Preliminary end-to-end benchmarks suggest that cheerio is about __8x__ faster than JSDOM.
__❁ Incredibly flexible:__
Cheerio wraps around [parse5](https://github.com/inikulin/parse5) parser and can optionally use @FB55's forgiving [htmlparser2](https://github.com/fb55/htmlparser2/). Cheerio can parse nearly any HTML or XML document.
## Cheerio is not a web browser
Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure. It does not interpret the result as a web browser does. Specifically, it does *not* produce a visual rendering, apply CSS, load external resources, or execute JavaScript. If your use case requires any of this functionality, you should consider projects like [PhantomJS](http://phantomjs.org/) or [JSDom](https://github.com/tmpvar/jsdom).
## Job Board
Looking for a career upgrade? Check out the available Node.js & Javascript positions at these innovative companies:
<a href="https://astro.netlify.com/automattic"><img src="https://astro.netlify.com/static/automattic.png"></a>
<a href="https://astro.netlify.com/segment"><img src="https://astro.netlify.com/static/segment.png"></a>
<a href="https://astro.netlify.com/auth0"><img src="https://astro.netlify.com/static/auth0.png"/></a>
## API
### Markup example we'll be using:
```html
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
```
This is the HTML markup we will be using in all of the API examples.
### Loading
First you need to load in the HTML. This step in jQuery is implicit, since jQuery operates on the one, baked-in DOM. With Cheerio, we need to pass in the HTML document.
This is the _preferred_ method:
```js
const cheerio = require('cheerio');
const $ = cheerio.load('<ul id="fruits">...</ul>');
```
Optionally, you can also load in the HTML by passing the string as the context:
```js
const $ = require('cheerio');
$('ul', '<ul id="fruits">...</ul>');
```
Or as the root:
```js
const $ = require('cheerio');
$('li', 'ul', '<ul id="fruits">...</ul>');
```
If you need to modify parsing options for XML input, you may pass an extra
object to `.load()`:
```js
const $ = cheerio.load('<ul id="fruits">...</ul>', {
xml: {
normalizeWhitespace: true,
}
});
```
The options in the `xml` object are taken directly from [htmlparser2](https://github.com/fb55/htmlparser2/wiki/Parser-options), therefore any options that can be used in `htmlparser2` are valid in cheerio as well. The default options are:
```js
{
withDomLvl1: true,
normalizeWhitespace: false,
xmlMode: true,
decodeEntities: true
}
```
For a full list of options and their effects, see [this](https://github.com/fb55/DomHandler) and
[htmlparser2's options](https://github.com/fb55/htmlparser2/wiki/Parser-options).
Some users may wish to parse markup with the `htmlparser2` library, and
traverse/manipulate the resulting structure with Cheerio. This may be the case
for those upgrading from pre-1.0 releases of Cheerio (which relied on
`htmlparser2`), for those dealing with invalid markup (because `htmlparser2` is
more forgiving), or for those operating in performance-critical situations
(because `htmlparser2` may be faster in some cases). Note that "more forgiving"
means `htmlparser2` has error-correcting mechanisms that aren't always a match
for the standards observed by web browsers. This behavior may be useful when
parsing non-HTML content.
To support these cases, `load` also accepts a `htmlparser2`-compatible data
structure as its first argument. Users may install `htmlparser2`, use it to
parse input, and pass the result to `load`:
```js
// Usage as of htmlparser2 version 3:
const htmlparser2 = require('htmlparser2');
const dom = htmlparser2.parseDOM(document, options);
const $ = cheerio.load(dom);
```
### Selectors
Cheerio's selector implementation is nearly identical to jQuery's, so the API is very similar.
#### $( selector, [context], [root] )
`selector` searches within the `context` scope which searches within the `root` scope. `selector` and `context` can be a string expression, DOM Element, array of DOM elements, or cheerio object. `root` is typically the HTML document string.
This selector method is the starting point for traversing and manipulating the document. Like jQuery, it's the primary method for selecting elements in the document, but unlike jQuery it's built on top of the CSSSelect library, which implements most of the Sizzle selectors.
```js
$('.apple', '#fruits').text()
//=> Apple
$('ul .pear').attr('class')
//=> pear
$('li[class=orange]').html()
//=> Orange
```
### Attributes
Methods for getting and modifying attributes.
#### .attr( name, value )
Method for getting and setting attributes. Gets the attribute value for only the first element in the matched set. If you set an attribute's value to `null`, you remove that attribute. You may also pass a `map` and `function` like jQuery.
```js
$('ul').attr('id')
//=> fruits
$('.apple').attr('id', 'favorite').html()
//=> <li class="apple" id="favorite">Apple</li>
```
> See http://api.jquery.com/attr/ for more information
#### .prop( name, value )
Method for getting and setting properties. Gets the property value for only the first element in the matched set.
```js
$('input[type="checkbox"]').prop('checked')
//=> false
$('input[type="checkbox"]').prop('checked', true).val()
//=> ok
```
> See http://api.jquery.com/prop/ for more information
#### .data( name, value )
Method for getting and setting data attributes. Gets or sets the data attribute value for only the first element in the matched set.
```js
$('<div data-apple-color="red"></div>').data()
//=> { appleColor: 'red' }
$('<div data-apple-color="red"></div>').data('apple-color')
//=> 'red'
const apple = $('.apple').data('kind', 'mac')
apple.data('kind')
//=> 'mac'
```
> See http://api.jquery.com/data/ for more information
#### .val( [value] )
Method for getting and setting the value of input, select, and textarea. Note: Support for `map`, and `function` has not been added yet.
```js
$('input[type="text"]').val()
//=> input_text
$('input[type="text"]').val('test').html()
//=> <input type="text" value="test"/>
```
#### .removeAttr( name )
Method for removing attributes by `name`.
没有合适的资源?快使用搜索试试~ 我知道了~
微信反编译工具最新版本
共1338个文件
js:1158个
ts:53个
json:51个
4星 · 超过85%的资源 需积分: 48 62 下载量 133 浏览量
2020-10-11
23:08:32
上传
评论 2
收藏 1.17MB ZIP 举报
温馨提示
最新款微信小程序反编译工具,可以完美解决no input,没有wxss文件等问题,自己已经亲身测试过,非常好用,包含wxss文件
资源推荐
资源详情
资源评论
收起资源包目录
微信反编译工具最新版本 (1338个子文件)
bingo.bat 718B
config 314B
description 73B
exclude 240B
HEAD 217B
HEAD 217B
HEAD 32B
HEAD 23B
pack-bc9a88a27bb21e6136802d2d6f9535c32a4ba7c4.idx 2KB
index 1KB
geek_road.jpg 27KB
lodash.js 530KB
core.js 113KB
index.js 86KB
named_entity_data.js 72KB
lodash.min.js 71KB
index.js 63KB
_stream_readable.js 35KB
Tokenizer.js 28KB
wuWxml.js 22KB
_stream_writable.js 21KB
_baseConvert.js 16KB
wuWxss.js 13KB
core.min.js 13KB
attributes.js 12KB
traversing.js 11KB
open_element_stack.js 11KB
manipulation.js 11KB
pseudos.js 10KB
_mapping.js 10KB
template.js 9KB
Parser.js 9KB
string_decoder.js 9KB
foreign_content.js 9KB
wuWxapkg.js 8KB
wuRestoreZ.js 8KB
htmlparser2.js 8KB
_stream_transform.js 8KB
wuConfig.js 8KB
parser_mixin.js 8KB
html.js 7KB
wrapperLodash.js 7KB
index.js 6KB
buffer_list.js 6KB
wuLib.js 6KB
debounce.js 6KB
async_iterator.js 6KB
test.js 6KB
doctype.js 6KB
_baseClone.js 5KB
static.js 5KB
index.js 5KB
compile.js 5KB
formatting_element_list.js 5KB
default.js 5KB
index.js 5KB
parser_feedback_simulator.js 5KB
_stream_duplex.js 4KB
attributes.js 4KB
tokenizer_mixin.js 4KB
errors-browser.js 4KB
preprocessor.js 4KB
helpers.js 4KB
FeedHandler.js 4KB
_equalByTag.js 4KB
errors.js 4KB
_createWrap.js 4KB
index.js 4KB
_deburrLetter.js 3KB
truncate.js 3KB
_createHybrid.js 3KB
legacy.js 3KB
from.js 3KB
_mergeData.js 3KB
destroy.js 3KB
end-of-stream.js 3KB
_baseMergeDeep.js 3KB
_unicodeWords.js 3KB
cheerio.js 3KB
_baseIsEqualDeep.js 3KB
_equalObjects.js 3KB
index.js 3KB
throttle.js 3KB
helpers.js 3KB
_equalArrays.js 3KB
forms.js 2KB
array.js 2KB
legacy.js 2KB
pipeline.js 2KB
css.js 2KB
random.js 2KB
wuJs.js 2KB
utils.js 2KB
transform.js 2KB
parse.js 2KB
_baseIntersection.js 2KB
_initCloneByTag.js 2KB
_baseSortedIndexBy.js 2KB
_createFlow.js 2KB
mixin.js 2KB
共 1338 条
- 1
- 2
- 3
- 4
- 5
- 6
- 14
资源评论
- 白菜的记录工具2021-07-30确实可以有wxss
- 叶隐霜2020-12-07我试过可以有wxss,就是得一个个下载npm包,
- tophunker1392022-06-20已下载试用了,可以用
- lin9681102021-06-23打开就可以用
- WWCZ222020-11-07有个锤wxss文件。2020年11月7日,测试这个工具毫无用处,浪费积分,不建议下载
背着行囊去远方
- 粉丝: 636
- 资源: 15
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功