$npx -y skills add EXboys/evotown --skill http-request发起 HTTP 网络请求,支持 GET、POST、PUT、DELETE、PATCH 方法。当用户需要调用 API、获取网页内容、发送数据到服务器时使用。
| 1 | # HTTP Request Skill |
| 2 | |
| 3 | 一个通用的 HTTP 网络请求技能,支持常见的 RESTful API 调用。 |
| 4 | |
| 5 | ## 功能特性 |
| 6 | |
| 7 | - 支持 GET、POST、PUT、DELETE、PATCH 方法 |
| 8 | - 支持自定义请求头 |
| 9 | - 支持 JSON 请求体 |
| 10 | - 支持 URL 查询参数 |
| 11 | - 支持超时设置 |
| 12 | - **旧版 SSL 兼容**:支持连接使用旧版 TLS 的服务器(如部分政府/教育网站) |
| 13 | - **浏览器级 User-Agent**:减少 503/反爬拦截 |
| 14 | - **Wikipedia/Wikimedia 合规**:访问 wikipedia.org / wikimedia.org / wikidata.org 时自动使用合规 User-Agent(否则易 403),并加 1.5 秒间隔降低限流 |
| 15 | - **自动重试**:对 502/503/504 自动重试 2 次 |
| 16 | - **HTML→Markdown**:网页响应自动转为 Markdown(默认),降低 token 消耗 |
| 17 | |
| 18 | ## 使用示例 |
| 19 | |
| 20 | ### GET 请求 |
| 21 | ```json |
| 22 | { |
| 23 | "url": "https://httpbin.org/get", |
| 24 | "method": "GET", |
| 25 | "params": {"name": "test"} |
| 26 | } |
| 27 | ``` |
| 28 | |
| 29 | ### POST 请求 |
| 30 | ```json |
| 31 | { |
| 32 | "url": "https://httpbin.org/post", |
| 33 | "method": "POST", |
| 34 | "headers": {"Content-Type": "application/json"}, |
| 35 | "body": {"message": "hello world"} |
| 36 | } |
| 37 | ``` |
| 38 | |
| 39 | ### 天气查询(推荐 Open-Meteo,免费无 key) |
| 40 | ```json |
| 41 | { |
| 42 | "url": "https://api.open-meteo.com/v1/forecast", |
| 43 | "method": "GET", |
| 44 | "params": { |
| 45 | "latitude": 18.7883, |
| 46 | "longitude": 98.9853, |
| 47 | "daily": "temperature_2m_max,temperature_2m_min,weathercode", |
| 48 | "timezone": "Asia/Bangkok", |
| 49 | "forecast_days": 2 |
| 50 | } |
| 51 | } |
| 52 | ``` |
| 53 | 清迈坐标 18.7883,98.9853。返回 JSON 含 daily.time、temperature_2m_max/min、weathercode。 |
| 54 | |
| 55 | wttr.in 亦可用:`https://wttr.in/Chiang_Mai?format=j1`,skill 会自动用 curl UA 以获取 JSON。 |
| 56 | |
| 57 | ### Wikipedia 获取城市/地点摘要(推荐,限流较宽松) |
| 58 | ```json |
| 59 | { |
| 60 | "url": "https://en.wikipedia.org/api/rest_v1/page/summary/Chiang_Mai", |
| 61 | "method": "GET" |
| 62 | } |
| 63 | ``` |
| 64 | 或 `.../page/summary/Bangkok`。返回 JSON 含 extract、description、title 等。 |
| 65 | |
| 66 | ### Wikipedia 搜索 API(params 可用 q,skill 会自动转为 action=query&list=search) |
| 67 | ```json |
| 68 | { |
| 69 | "url": "https://en.wikipedia.org/w/api.php", |
| 70 | "method": "GET", |
| 71 | "params": {"q": "Chiang Mai tourism"} |
| 72 | } |
| 73 | ``` |
| 74 | |
| 75 | ## Runtime |
| 76 | |
| 77 | ```yaml |
| 78 | entry_point: scripts/main.py |
| 79 | language: python |
| 80 | network: |
| 81 | enabled: true |
| 82 | outbound: |
| 83 | - "*:80" |
| 84 | - "*:443" |
| 85 | block_private_ips: false |
| 86 | input_schema: |
| 87 | type: object |
| 88 | properties: |
| 89 | url: |
| 90 | type: string |
| 91 | description: 请求的完整 URL |
| 92 | method: |
| 93 | type: string |
| 94 | description: HTTP 请求方法 |
| 95 | enum: |
| 96 | - GET |
| 97 | - POST |
| 98 | - PUT |
| 99 | - DELETE |
| 100 | - PATCH |
| 101 | default: GET |
| 102 | headers: |
| 103 | type: object |
| 104 | description: 自定义请求头 |
| 105 | additionalProperties: |
| 106 | type: string |
| 107 | body: |
| 108 | type: object |
| 109 | description: 请求体数据,用于 POST/PUT/PATCH,将以 JSON 格式发送 |
| 110 | params: |
| 111 | type: object |
| 112 | description: URL 查询参数 |
| 113 | additionalProperties: true |
| 114 | timeout: |
| 115 | type: number |
| 116 | description: 请求超时时间(秒),默认 30 秒 |
| 117 | default: 30 |
| 118 | use_legacy_ssl: |
| 119 | type: boolean |
| 120 | description: 是否启用旧版 SSL 兼容(连接 cscse.edu.cn、lxgz.org.cn 等旧服务器时需 true) |
| 121 | default: true |
| 122 | extract_mode: |
| 123 | type: string |
| 124 | description: HTML 响应提取模式,markdown=转为 Markdown(默认),text=纯文本,raw=原始 HTML |
| 125 | enum: |
| 126 | - markdown |
| 127 | - text |
| 128 | - raw |
| 129 | default: markdown |
| 130 | required: |
| 131 | - url |
| 132 | ``` |