问题
每个月,Hacker News 都会举办一个广受欢迎的帖子:“Ask HN: 谁正在招聘?”这是一个巨大的工作机会宝库,但滚动浏览无尽的文本墙以找到你的梦想职位,就像大海捞针一样。
解决方案
我用 Cursor 编写了一个小项目,它利用 OpenAI 进行解析,PostgreSQL 进行存储,以及 Metabase 进行可视化,将 Hacker News 的招聘帖子转换为清晰、可搜索的数据。这正是数据整理的“圣三位一体”:)
它能做什么
- 通过 Hacker News API 获取“Ask HN: 谁正在招聘?”帖子
- 使用 GPT 提取公司、职位、地点、薪资和联系方式等字段
- 将所有数据存储在 PostgreSQL 数据库中
- 启动 Metabase,以便您可以搜索、过滤和探索数据
工作原理
获取帖子
该脚本使用其 ID 拉取特定的 Hacker News 帖子(您可以从任何“Ask HN: Who is hiring?”帖子的 URL 中获取此 ID)。
使用 GPT 解析评论
我最初尝试使用正则表达式,但每条评论中非结构化的格式使得获取清晰、可靠的数据变得不可能。因此,我转向了 GPT。每条评论都通过结构化提示传递给 OpenAI,以 JSON 格式提取相关字段。这是提示的核心部分
OPENAI_PROMPT = (
"You are a structured data parser for Hacker News job posts. "
"Extract the following fields as plain strings (no quotes, arrays, or brackets unless necessary):\n"
"- company: the name of the hiring company\n"
"- role: the job title or position name\n"
"- location: city/state/country or 'Remote' if applicable\n"
"- salary: salary range or note (e.g. '$120k--$150k', 'Competitive', etc.)\n"
"- contact: email address or direct application link (cleaned, no obfuscation like [at] or [dot])\n"
"- description: a cleaned-up version of the full job post, useful for search\n\n"
"Requirements:\n"
"- Output a flat JSON object using the keys above\n"
"- If any field is missing or not available, use null\n"
"- Do not include markdown, HTML, or formatting characters\n"
"- Fix obfuscated emails like 'name [at] domain [dot] com'\n"
"- Output only the JSON object, with no extra commentary.\n"
"- No trailing commas.\n\n"
"Job post:\n"
'\"\"\"{job_text}\"\"\"'
)
存储在 PostgreSQL 中
解析结果保存在一个 jobs 表中
CREATE SCHEMA IF NOT EXISTS hn;
CREATE TABLE hn.jobs (
hn_comment_id bigint primary key,
company text,
role text,
location text,
salary text,
contact text,
description text,
posted_at timestamp with time zone,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
在 Metabase 中探索
Metabase 直接连接到 Postgres 数据库,为您提供一个干净的用户界面来探索数据。
我做了一个小表格,让你能够
- 按公司、职位、地点和薪资筛选
- 链接到帖子 ID

潜在增强功能
以下是一些将此项目提升到新水平的想法
- 自动化每月更新:使用 GitHub Actions 每月自动获取和解析新的“Ask HN: 谁正在招聘?”帖子。
- 部署公共仪表板:分享一个 实时 Metabase 仪表板,供任何人探索职位列表,而无需运行代码。
- 添加通知提醒:设置 电子邮件或 Slack 通知,以获取符合特定条件(如职位或地点)的新招聘信息。
试用并贡献
在 GitHub 上查看完整的代码和详细的设置说明。无论您是在寻找下一个职位还是只是好奇,都可以随意克隆仓库并试用。更好的是,考虑贡献。如果您有功能想法、错误修复或任何改进,请提交拉取请求或提出问题。
感谢您的阅读,祝您求职顺利!