百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

parser

> 测试质量
开源

从网页的混乱中提取有意义的内容

5.8K stars0 点赞3 次浏览
访问官网GitHub

工具介绍

从网页的混乱中提取有意义的内容

Postlight Parser - 从混乱中提取内容

Apache License MITC License

Postlight Parser 为 Postlight Reader 提供支持,这是一款浏览器扩展,可以去除广告和干扰内容,只保留文本和图片,在任何网站上都能获得美观的阅读视图。

Postlight Parser 允许你使用简单的 JavaScript 和 CSS 选择器轻松创建自定义解析器。这让你能够主动管理解析和迁移中的边缘情况。这里有许多可用的示例以及文档。

怎么做?就像这样。

安装

bash
# If you're using yarn
yarn add @postlight/parser

# If you're using npm
npm install @postlight/parser

用法

javascript
import Parser from '@postlight/parser';

Parser.parse(url).then(result => console.log(result));

// NOTE: When used in the browser, you can omit the URL argument
// and simply run `Parser.parse()` to parse the current page.

结果如下所示:

…

如果 Parser 无法找到某个字段,该字段将返回 null。

parse() 选项

内容格式

默认情况下,Postlight Parser 以 HTML 格式返回 content 字段。不过,你可以通过向 parse 函数传入选项来覆盖这一行为,指定是否抓取文章的所有页面,以及要返回的输出类型(有效值为 'html'、`'ma

Postlight's Parser extracts the bits that humans care about from any URL you give it. That includes article content, titles, authors, published dates, excerpts, lead images, and more.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptjestlabsmercurymercury-parser

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类测试质量
定价开源

> 相关工具

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.