LeoYeAI/agent-master-skills / skills/baidu-search
baidu-search
VerifiedSearch the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 1.4 KB |
| scripts/search.py | script | 3.4 KB |
scripts/search.py
View on GitHubimport sys
import json
import requests
import os
import re
from datetime import datetime, timedelta
def baidu_search(api_key, requestBody: dict):
url = "https://qianfan.baidubce.com/v2/ai_search/web_search"
headers = {
"Authorization": "Bearer %s" % api_key,
"X-Appbuilder-From": "openclaw",
"Content-Type": "application/json"
}
# 使用POST方法发送JSON数据
response = requests.post(url, json=requestBody, headers=headers)
response.raise_for_status()
results = response.json()
if "code" in results:
raise Exception(results["message"])
datas = results["references"]
keys_to_remove = {"snippet"}
for item in datas:
for key in keys_to_remove:
if key in item:
del item[key]
return datas
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python baidu_search.py <Json>")
sys.exit(1)
query = sys.argv[1]
parse_data = {}
try:
parse_data = json.loads(query)
print(f"success parse request body: {parse_data}")
except json.JSONDecodeError as e:
print(f"JSON parse error: {e}")
if "query" not in parse_data:
print("Error: query must be present in request body.")
sys.exit(1)
count = 10
search_filter = {}
if "count" in parse_data:
count = int(parse_data["count"])
if count <= 0:
count = 10
elif count > 50:
count = 50
current_time = datetime.now()
end_date = (current_time + timedelta(days=1)).strftime("%Y-%m-%d")
pattern = r'\d{4}-\d{2}-\d{2}to\d{4}-\d{2}-\d{2}'
if "freshness" in parse_data:
if parse_data["freshness"] in ["pd", "pw", "pm", "py"]:
if parse_data["freshness"] == "pd":
start_date = (current_time - timedelta(days=1)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "pw":
start_date = (current_time - timedelta(days=6)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "pm":
start_date = (current_time - timedelta(days=30)).strftime("%Y-%m-%d")
if parse_data["freshness"] == "py":
start_date = (current_time - timedelta(days=364)).strftime("%Y-%m-%d")
search_filter = {"range": {"page_time": {"gte": start_date, "lt": end_date}}}
elif re.match(pattern, parse_data["freshness"]):
start_date = parse_data["freshness"].split("to")[0]
end_date = parse_data["freshness"].split("to")[1]
search_filter = {"range": {"page_time": {"gte": start_date, "lt": end_date}}}
else:
print(f"Error: freshness ({parse_data['freshness']}) must be pd, pw, pm, py, or match {pattern}.")
sys.exit(1)
# We will pass these via env vars for security
api_key = os.getenv("BAIDU_API_KEY")
if not api_key:
print("Error: BAIDU_API_KEY must be set in environment.")
sys.exit(1)
request_body = {
"messages": [
{
"content": parse_data["query"],
"role": "user"
}
],
"search_source": "baidu_search_v2",
"resource_type_filter": [{"type": "web", "top_k": count}],
"search_filter": search_filter
}
try:
results = baidu_search(api_key, request_body)
print(json.dumps(results, indent=2, ensure_ascii=False))
except Exception as e:
print(f"Error: {str(e)}")
sys.exit(1)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |