登录 注册
其他
2,149
Stars
0
Forks
0
Watchers
0
Open Issues
未知
许可证
Elixir
语言
创建时间
最近更新

项目能做什么

简易 HTML 解析器,支持使用 CSS 选择器来搜索节点。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
[![Actions Status](https://github.com/philss/floki/actions/workflows/ci.yml/badge.svg)](https://github.com/philss/floki/actions/workflows/ci.yml)
[![Floki version](https://img.shields.io/hexpm/v/floki.svg)](https://hex.pm/packages/floki)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/floki/)
[![Hex.pm](https://img.shields.io/hexpm/dt/floki.svg)](https://hex.pm/packages/floki)
[![License](https://img.shields.io/hexpm/l/floki.svg)](https://github.com/philss/floki/blob/main/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/philss/floki.svg)](https://github.com/philss/floki/commits/main)

<img src="assets/images/floki-logo-with-type.svg" width="500" alt="Floki logo">

**Floki is a simple HTML parser that enables search for nodes using CSS selectors**.

[Check the documentation 📙](https://hexdocs.pm/floki).

## Usage

Take this HTML as an example:

```html
<!DOCTYPE html>
<html>
  <body>
    <section id="content">
      <p class="headline">Floki</p>
      <span class="headline">Enables search using CSS selectors</span>
      <a href="https://github.com/philss/floki">Github page</a>
      <span data-model="user">philss</span>
    </section>
    <a href="https://hex.pm/packages/floki">Hex package</a>
  </body>
</html>
```

Here are some queries that you can perform (with return examples):

```elixir
{:ok, document} = Floki.parse_document(html)

Floki.find(document, "p.headline")
# => [{"p", [{"class", "headline"}], ["Floki"]}]

document
|> Floki.find("p.headline")
|> Floki.raw_html()
# => <p class="headline">Floki</p>
```

Each HTML node is represented by a tuple like:

    {tag_name, attributes, children_nodes}

Example of node:

    {"p", [{"class", "headline"}], ["Floki"]}

So even if the only child node is the element text, it is represented inside a list.

## Installation

Add Floki to your `mix.exs`:

```elixir
defp deps do
  [
    {:floki, "~> 0.38.0"}
  ]
end
```

After that, run `mix deps.get`.

If you are running on [Livebook](https://livebook.dev) or a script, you can install with `Mix.install/2`:

```elixir
Mix.install([
  {:floki, "~> 0.38.0"}
])
```

You can check the [changelog](CHANGELOG.md) for changes.

## Dependencies

Floki needs the `:leex` module in order to compile.
Normally this module is installed with Erlang in a complete installation.

If you get this ["module :leex is not available"](https://github.com/philss/floki/issues/35) error message, you need to install the `erlang-dev` and `erlang-parsetools` packages in order get the `:leex` module. The packages names may be different depending on your OS.

### Alternative HTML parsers

By default Floki uses a patched version of `mochiweb_html` for parsing fragments
due to its ease of installation (it's written in Erlang and has no outside dependencies).

However one might want to use an alternative parser due to the following
concerns:

- Performance - It can be [up to 20 times slower than the alternatives](https://hexdocs.pm
阅读完整原文

商业机会分析 AI 生成

基于 Elixir/Floki 的托管式高并发网页数据提取 API (SaaS)

产品构想利用 Elixir 强大的并发性能与 Floki 解析能力,构建开箱即用的云端网页抓取与结构化提取服务,提供代理轮换、JS 渲染和 CSS 规则抽取。
核心功能URL 提交接口、CSS/Floki 选择器配置引擎、无头浏览器动态渲染切换、自动重试与反爬轮换、JSON 格式化导出。
目标用户需要抓取公开网页但不想自建代理池和爬虫架构的中小企业及独立开发者。
难度/周期中等 · 1-2 个月 · 成本:服务器(BEAM 节点)、代理 IP 流量成本、无头浏览器渲染资源成本(推测约 $100-$300/月)。
收费模式按请求量阶梯计费(订阅制 SaaS,如 $29/月包 10 万次成功抓取)。
竞争风险代理 IP 成本高昂,目标网站反爬策略频繁更新导致维护成本高。
依据 AI推测

LLM 专用的 HTML 降噪与 Markdown 清洗微服务

产品构想针对 RAG 和大模型上下文窗口,利用 Floki 的高性能树遍历与剪枝能力,移除无关 DOM(广告、脚本、导航),输出高保真 Markdown/结构化文本。
核心功能智能主干文本提取算法、HTML 到清爽 Markdown 转换、Token 优化压缩、REST/gRPC 接口提供。
目标用户构建 RAG 系统、AI Agent、知识库的开发者与团队。
难度/周期较低 · 2-4 周 · 成本:轻量云主机,推测约 $20-$50/月。
收费模式按清洗量订阅或 API 调用量计费,提供私有部署 License。
竞争风险各类开源 Readability 方案竞争激烈,需在速度(Elixir/Rust NIF)和清洗质量上形成壁垒。
依据 尚需验证的假设

Phoenix/LiveView 网页变动监控与告警平台

产品构想基于 Elixir 生态构建轻量级网页内容监控服务,用户指定 URL 和 Floki 选择器,系统定时抓取并比对节点变动,触发 Webhook/邮件告警。
核心功能可视化的 CSS 选择器点选器、周期性后台抓取任务(Oban)、DOM 差异比对(Diff)、多渠道通知推送。
目标用户电商竞品监控人员、合规审查团队、价格追踪个人用户。
难度/周期中等 · 1 个月 · 成本:基础服务器与发信服务,推测约 $30-$80/月。
收费模式免费额度 + 增值订阅(高频监控如 5 分钟一次、更多监控项收费)。
竞争风险同类竞品较多(如 Visualping),需要依托高并发极低成本来打性价比策略。
依据 AI推测
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
denisidoro/floki 中文介绍暂未生成
A JSON/EDN browser for the terminal
316 Clojure
Cyb3rWard0g/floki 中文介绍暂未生成
Agentic Workflows Made Simple
166 Python
arthurprs/floki 中文介绍暂未生成
Floki Message Queue
90 Rust
Metaswitch/floki 中文介绍暂未生成
Launch containers to help build your software
73 Rust
sergiocardoso/flokin-md 中文介绍暂未生成
A local-first database for your Markdown files
39 Rust
wednesday-solutions/react-floki 中文介绍暂未生成
A CLI tool that works with the react template and allows you
38 JavaScript
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 ,最近推送 ,发布过 22 个 Release
社区活跃Star 2,149 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/philss/floki.git
cd floki
# 请阅读仓库 README 获取确切安装步骤(依赖、配置、启动命令)
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。