r/crewai 帖子记录了一个 SDR 代理,它使用 Serper 上的 Google Dorks 加上 pdfplumber 加上 Llama-3 加上 MCP 缓存。本教程将 Serper 替换为 Scavio,并展示了具有类型化 JSON 缓存的相同模式。
前置条件
- Python 3.10+
- 船员人工智能
- Scavio API 密钥
操作指南
步骤 1: 定义 Scavio CrewAI 工具
CrewAI 的 BaseTool 的子类。
Python
from crewai.tools import BaseTool
import requests, os
class ScavioSearch(BaseTool):
name = 'scavio_search'
description = 'Multi-platform web search returning typed JSON. Use search_type="dorks" for Google Dorks.'
def _run(self, query: str):
return requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
json={'query': query}).json()步骤 2: 定义 Google Dorks 查询模式
与原版相同的傻琴弦。
Python
DORK_PATTERNS = [
'site:gov.br filetype:pdf 2026 contratos',
'site:gob.mx filetype:pdf 2026 licitaciones'
]步骤 3: 定时任务驱动程序
相同的 cron,交换 API。
Bash
# crontab -e
# 0 6 * * * /usr/bin/python /path/to/dorks.py步骤 4: SQLite 中的缓存层(现在输入 JSON)
缓存键=(查询,表面)。值 = JSON 字符串。
Python
import sqlite3, json
conn = sqlite3.connect('cache.db')
conn.execute('CREATE TABLE IF NOT EXISTS cache(key TEXT PRIMARY KEY, payload TEXT, ts REAL)')
def cached_search(q):
row = conn.execute('SELECT payload FROM cache WHERE key=?', (q,)).fetchone()
if row: return json.loads(row[0])
data = ScavioSearch()._run(q)
conn.execute('INSERT OR REPLACE INTO cache VALUES (?, ?, ?)', (q, json.dumps(data), 0))
conn.commit()
return data步骤 5: 插入 CrewAI 代理
相同的代理形状,Scadio 工具取代了 Serper 工具。
Python
from crewai import Agent
researcher = Agent(role='Government Bid Researcher', tools=[ScavioSearch()])Python 示例
Python
# See steps above for full pattern.JavaScript 示例
JavaScript
// CrewAI is Python-first; equivalent Mastra/JS pattern uses Scavio HTTP directly.预期输出
JSON
SDR agent fetches government bid PDFs the same as before, now with Reddit thread surfacing as a second source layer at no additional vendor.