LoginSignup
2
1

More than 5 years have passed since last update.

Cheerioのchildren()とcontents()の違い

Last updated at Posted at 2014-10-29

Cheerioで次のような構造のDOMを扱いたいとします。

hn.png

children()

$('td.subtext').children();

3つのノードが取得されます。

<span></span>
<a href></a>
<a href></a>

contents()

$('td.subtext').contents();

5つのノードが全て取得されます。

<span></span>
" by "
<a href></a>
" 3 hours ago  | "
<a href></a>

以上です。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1