问题
每个月,Hacker News 都会举办一个非常受欢迎的帖子:“Ask HN: Who is hiring?”(求职招聘问答)。这是一个巨大的工作机会宝库,但要想在无尽的文本中找到你的梦想职位,感觉就像大海捞针。
解决方案
我与 Cursor 轻松编写了一个小项目,它利用 OpenAI 进行解析、PostgreSQL 进行存储、Metabase 进行可视化,将 Hacker News 上的招聘信息转换为干净、可搜索的数据。这是数据处理的三位一体 :)
功能
- 通过 Hacker News API 获取“Ask HN: Who is hiring?”帖子
- 使用 GPT 提取公司、职位、地点、薪资和联系方式等字段
- 将所有数据存储在 PostgreSQL 数据库中
- 启动 Metabase,以便您可以搜索、筛选和探索数据
工作原理
获取帖子
该脚本使用帖子 ID(您可以从任何“Ask HN: Who is hiring?”帖子的 URL 中获取)拉取特定的 Hacker News 帖子。
使用 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 数据库,并为您提供简洁的 UI 供您探索数据。
我创建了一个小表格,它允许您
- 按公司、职位、地点和薪资筛选
- 链接到帖子 ID
潜在增强功能
以下是一些将此项目提升到新水平的想法
- 自动化每月更新: 使用 GitHub Actions 每月自动获取和解析新的“Ask HN: Who is hiring?”帖子。
- 部署公共仪表盘: 共享一个实时 Metabase 仪表盘,供任何人探索招聘信息,无需运行代码。
- 添加通知提醒: 设置电子邮件或 Slack 通知,以便在新招聘信息符合特定条件(如职位或地点)时收到提醒。
试用并贡献
请在GitHub 上查看完整的代码和详细设置说明。无论您是在寻找下一个职位,还是仅仅出于好奇,都可以随意克隆此仓库并尝试一下。更好的是,考虑做出贡献。如果您有功能想法、错误修复或任何改进,请提交拉取请求或提出问题。
感谢阅读,祝您求职顺利!