Skip to content

About

"LLM-driven browser automation for tech job search"

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

🦊 P1 Browser Agent

GitHub stars GitHub forks Python License Status

让 LLM 帮你浏览招聘网站、自动抓取 JD 的浏览器 Agent
ReAct 范式 + Playwright + 模块化架构 · 从零到一构建求职 Agent


🎯 项目介绍

求职季每天刷 100+ 个 JD 是不是让你眼睛酸、脖子僵?P1 Browser Agent 是一个基于大语言模型的浏览器自动化 Agent,输入一句中文求职需求,它就能自动打开招聘网站、抓取职位信息、输出结构化的 Excel + Markdown 报告。

这不是又一个爬虫脚本——这是一个真正用 LLM 大脑 + 工具调用构建的 Agent。它完整实现了 ReAct (Reason + Act) 范式:LLM 思考 → 调用浏览器工具 → 观察结果 → 继续思考,循环直到任务完成。架构上做了通用抽象:不只限求职,未来可以扩展到任何网站(产品调研、论文抓取、社交媒体分析等)。

本项目是作者 4.5 个月 AI Agent 学习计划的 P1 阶段(Phase 1 — 第一个 demo 项目),目标是在 2-3 周内完成一个端到端可跑通的 Agent MVP,作为求职简历的核心展示项目和后续 P2/P3 扩展的基础。

✨ 你将收获什么?

  • 理解 ReAct 范式 — 不是看论文,而是手写一个 ReAct Loop,看 LLM 如何思考-调用-观察
  • LLM Tool Use 实战 — 让 MiniMax-M3 通过 function calling 调度浏览器工具
  • Playwright 跨浏览器自动化 — 真实驱动 Chrome 抓取招聘网站
  • 模块化架构 — 4 模块(core / platforms / llm / output)+ 可扩展 schema,未来加新平台只需 50 行
  • 严格 TDD — 25 个测试全过,0 警告
  • 结构化输出 — 10 字段 Excel + Markdown 报告
  • 偏好学习 — 第二次跑自动应用上次的设置(地点/关键词/数量)

🧠 ReAct 架构

用户输入: 深圳 AI Agent 实习 20 个
        |
        v
+----------------------------+
|  CLI (typer)              |  ← 命令行入口
+----------------------------+
        |
        v
+----------------------------+
|  NL Parser                |  ← 中文/英文都支持
+----------------------------+
        |
        v
+----------------------------+
|  ReAct Loop               |  ← 核心算法
|  (core/agent.py)          |
+----------------------------+
   |       |       |
   v       v       v
+------+ +------+ +------+
|  LLM | |Tools| |State|
+------+ +------+ +------+
        |       |
        v       v
   +-------+  +--------+
   |OpenAI |  |Memory  |  ← 持久化偏好
   |compat |  |prefs   |
   +-------+  +--------+
        |
        v
+----------------------------+
|  PlatformAdapter         |  ← 实习僧 + Boss
|  (platforms/*.py)        |
+----------------------------+
        |
        v
+----------------------------+
|  Output                   |  ← Excel + Markdown
+----------------------------+

ReAct 单次循环

Thought:  用户想找 AI Agent 实习,我应该打开 Boss直聘
   |
   v
Action:   navigate(https://zhipin.com/...)
   |
   v
Observation: [HTML 内容]
   |
   v
Thought:  找到搜索框,输入关键词
   |
   v
Action:   search(AI Agent, 深圳)
   |
   v
Observation: [搜索结果 HTML]
   |
   v
Thought:  提取职位信息
   |
   v
Action:   extract_topics()
   |
   v
Observation: [10 个 JobTopic]
   |
   v
Thought:  够了,结束
   |
   v
Action:   done(reason=extracted 10 JDs)

🚀 快速开始

安装

# 1. 克隆仓库
git clone https://github.com/Cool-11/p1-browser-agent.git
cd p1-browser-agent

# 2. 安装依赖(需要 uv)
uv sync

# 3. 安装 Playwright 浏览器二进制
uv run playwright install chromium

# 4. 配置 API key
cp .env.example .env
# 编辑 .env,填入你的 MiniMax API key

使用

# 默认: 20 个 JD,实习僧 + Boss 同时
uv run p1-agent "深圳 AI Agent 实习"

# 自定义数量
uv run p1-agent "深圳 AI Agent 实习" --max 50

# 只跑一个平台
uv run p1-agent "深圳 AI Agent 实习" --platforms shixiseng

# 健康检查
uv run p1-agent doctor

输出示例

执行后会在 output/ 下生成:

  • jobs_20260825_HHMMSS.xlsx — 10 字段 Excel 表格
  • jobs_20260825_HHMMSS.md — Markdown 分析报告

📁 项目结构

p1-browser-agent/
|-- README.md              # 本文件
|-- pyproject.toml         # uv 包配置
|-- .env.example           # 环境变量模板
|-- agent.py               # CLI 入口(typer)
|-- core/                  # 核心逻辑
|   |-- agent.py           # ReAct Loop
|   |-- state.py           # AgentState + IntentQuery
|   |-- parser.py          # NL -> IntentQuery
|   |-- extractor.py       # TopicExtractor
|-- platforms/             # 招聘平台 adapters
|   |-- base.py            # PlatformAdapter ABC
|   |-- shixiseng.py       # 实习僧
|   |-- boss.py            # Boss直聘
|-- llm/                   # LLM 客户端
|   |-- client.py
|-- schemas/               # 数据模型
|   |-- job.py
|-- memory/                # 偏好记忆
|   |-- preferences.py
|-- output/                # 输出
|   |-- excel_writer.py
|   |-- markdown_writer.py
|-- tests/                 # 25 个测试
|-- docs/                  # 设计文档

📊 抽取的 10 个字段

字段 类型 示例
title str AI Agent 实习生
company str MiniMax
salary str? 200-300/天
location str 深圳
job_type str 实习
experience_required str? 不限
education_required str? 本科
published_at str? 2026-08-20
skills_summary list[str] [Python, LangChain]
url str https://...
platform str shixiseng / boss
raw_html_hash str 去重用

🧪 开发

# 跑全部测试(25 个)
& ".venv\Scripts\python.exe" -m pytest -v

# 跑单个测试文件
& ".venv\Scripts\python.exe" -m pytest tests/test_react_loop.py -v

# 跑覆盖率
& ".venv\Scripts\python.exe" -m pytest --cov=core --cov=platforms

添加新的招聘平台

  1. 创建 platforms/newsite.py,继承 PlatformAdapter
  2. 实现 3 个方法:search() / extract_topics() / next_page()
  3. 在 agent.py 的 PLATFORM_REGISTRY 注册
  4. 写测试 + commit

🛣️ Roadmap

  • P1 (MVP) — 2 平台 CLI,20 个 JD,端到端跑通
  • P2 — 加拉勾/猎聘 + 持久化登录 + MCP server
  • P3 — 录屏 demo 视频 + 质量评分 + 跨平台压力测试

🎯 适用人群

  • 正在求职 AI Agent / LLM 方向的在校生(直接用这个项目找实习)
  • 在职工程师想转行 AI Agent(拿这个项目当面试 demo)
  • 任何想理解 ReAct 范式 + 工具调用的 Python 开发者

📚 参考文献

📝 License

MIT

About

"LLM-driven browser automation for tech job search"

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages