职位爬取服务

一个独立的Python微服务,用于爬取最新的职位列表,存储在SQLite中并进行去重,通过REST端点提供职位数据。

  • by itsyashvardhan
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 itsyashvardhan/mcp-server

使用说明

MCP服务器

一个独立的Python微服务 抓取新的工作列表 使用 Jobspy,将它们存储在具有重复数据删除功能的SQLite中,并公开 /jobs REST端点 用于作为实时提要嵌入到投资组合网站中。


特性

  • 多站点抓取
  • 分层角色搜索
  • 智能重复数据删除
  • APScheduler
  • 查询过滤
  • CORS已启用
  • 部署就绪

建筑

APScheduler (1hr)  →  Jobspy Scraper  →  SQLite (deduped)  ←  FastAPI /jobs
                                                                    ↕
                                                          Portfolio Site (fetch)

快速开始

1.克隆和安装

cd jobs-mcp-server
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

2.配置

cp .env.example .env
# Edit .env as needed

3.跑步

python main.py

服务器启动于 http://localhost:8000初始刮擦在后台自动运行。


API终点

GET / --健康检查

{
  "status": "healthy",
  "service": "Job Listings MCP Server",
  "total_jobs_in_db": 142,
  "scrape_interval_hours": 1
}

GET /jobs --列出工作列表

查询参数:

参数 类型 描述
location string 按位置筛选(子字符串,不区分大小写)
keyword string 按职位中的关键字筛选
hours int 仅在过去N小时内删除的作业
limit int 最大结果(默认100,最大500)
offset int 分页偏移量

例子:

curl "http://localhost:8000/jobs?location=San%20Francisco&keyword=AI&hours=24"

答复:

{
  "count": 5,
  "filters": {
    "location": "San Francisco",
    "keyword": "AI",
    "hours": 24
  },
  "jobs": [
    {
      "id": 1,
      "job_title": "AI Solutions Engineer",
      "company": "Acme Corp",
      "location": "San Francisco, CA",
      "salary": "USD 120,000–160,000/yearly",
      "apply_link": "https://linkedin.com/jobs/...",
      "date_posted": "2025-01-15",
      "date_scraped": "2025-01-15T12:00:00+00:00",
      "source_site": "linkedin",
      "role_tier": "T2 — Secondary"
    }
  ]
}

POST /scrape --手动触发器

在后台触发刮擦运行。

curl -X POST http://localhost:8000/scrape

GET /status --上次报废状态

curl http://localhost:8000/status

GET /roles --配置的角色层

curl http://localhost:8000/roles

部署

铁路

  1. 叉起 mcp-server repo到新的GitHub repo(或子目录)。
  2. 将铁路连接到回购。
  3. 铁路自动检测到Dockerfile。
  4. 添加一个 体积 在 /data 以持久化SQLite数据库。
  5. 在铁路仪表板中设置环境变量。

渲染

  1. 创建新 网络服务.
  2. 指向repo/目录。
  3. 集 构建命令: pip install -r requirements.txt
  4. 集 启动命令: python main.py
  5. 添加一个 磁盘 在 /data 并设置 DATA_DIR=/data.

🔗 投资组合整合

在Next.js组合中,从部署的URL获取:

// In a Next.js API route or client component
const API_URL = process.env.NEXT_PUBLIC_JOBS_API_URL || 'https://your-jobs-server.up.railway.app';

async function fetchJobs(filters?: { location?: string; keyword?: string; hours?: number }) {
  const params = new URLSearchParams();
  if (filters?.location) params.set('location', filters.location);
  if (filters?.keyword) params.set('keyword', filters.keyword);
  if (filters?.hours) params.set('hours', String(filters.hours));

  const res = await fetch(`${API_URL}/jobs?${params.toString()}`);
  return res.json();
}

许可证

麻省理工学院