0.8.3 • Published 5 years ago

temme v0.8.3

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage Status NPM Package Node Version Requirement VSCode Extension Example Fangwen Example Douban Movie

English Version

temme

temme 是一个类 jQuery 的选择器,用于简洁优雅地从 HTML 文档中提取所需的 JSON 数据。

NEWS

✨ 新版网站处于 beta 阶段,欢迎大家试用。 https://temmejs.org

相关链接

例子

<!-- 下面用到的 html 的内容 -->
<ul>
  <li data-fruit-id="1">
    <span data-color="red">apple</span>
  </li>
  <li data-fruit-id="2">
    <span data-color="white">pear</span>
  </li>
  <li data-fruit-id="3">
    <span data-color="purple">grape</span>
  </li>
</ul>

对于上面的 html,我们可以使用下面的 temme 选择器来提取「水果颜色和名称的列表」。(在线版本链接

import temme from 'temme'

const selector = `li@fruits {
  span[data-color=$color]{$name};
}`
temme(html, selector)
//=>
// {
//   "fruits": [
//     { "color": "red", "name": "apple" },
//     { "color": "white", "name": "pear"  },
//     { "color": "purple", "name": "grape" }
//   ]
// }

如果你对 temme 还不熟悉,那么可以从 豆瓣电影的例子 开始。在线版本中也包含了一些其他较短的例子。比如这个例子从豆瓣电影页面中抓取了电影的基本信息和评分信息。这个例子从天猫的商品详情页面中抓取了评论列表,包括用户的基本信息,初次评价和追加评价, 以及晒的照片的链接.

0.8.3

5 years ago

0.8.2

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago