从网页的混乱中提取有意义的内容
Postlight Parser 为 Postlight Reader 提供支持,这是一款浏览器扩展,可以去除广告和干扰内容,只保留文本和图片,在任何网站上都能获得美观的阅读视图。
Postlight Parser 允许你使用简单的 JavaScript 和 CSS 选择器轻松创建自定义解析器。这让你能够主动管理解析和迁移中的边缘情况。这里有许多可用的示例以及文档。
# If you're using yarn
yarn add @postlight/parser
# If you're using npm
npm install @postlight/parserimport 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,或尚未同步最近议题。