一键导入
weather
Get weather information using system commands and offline methods without external APIs. Use when you need weather data and want to avoid API dependencies.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Get weather information using system commands and offline methods without external APIs. Use when you need weather data and want to avoid API dependencies.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Business analysis and requirements specialist. Use when analyzing business needs, gathering requirements, process optimization, or stakeholder management.
Debugging specialist mode. Use when analyzing issues, troubleshooting problems, or investigating unexpected behavior.
Mentoring and coaching specialist. Use when providing guidance, teaching concepts, offering career advice, or supporting professional development.
Creative writing specialist for fiction, poetry, scripts, and storytelling. Use when writing stories, poems, scripts, or any creative content.
Academic and creative essay writing specialist. Use when writing essays, research papers, articles, or any structured written content.
Strategic planning and project management specialist. Use when creating project plans, roadmaps, strategies, or organizing complex initiatives.
| name | weather |
| description | Get weather information using system commands and offline methods without external APIs. Use when you need weather data and want to avoid API dependencies. |
Weather data typically requires external APIs for accurate, real-time information. This skill provides methods to get weather without APIs using system commands, offline databases, and local sources. For accurate weather, consider using free weather APIs (OpenWeatherMap, WeatherAPI, etc.).
# Install weather-util
sudo apt-get install weather-util
# Get current weather
weather "New York"
# Get weather by airport code
weather "KJFK"
# Get weather in metric units
weather -m "London"
# Get forecast
weather -f "Paris"
# Install weget
sudo apt-get install weget
# Get weather
weget "Tokyo"
# Install weather-cli
brew install weather-cli
# Get weather
weather "San Francisco"
# Get forecast
weather -f "Los Angeles"
# Using built-in weather (Windows 10/11)
# Note: This may require specific Windows versions
# Alternative: Use curl to fetch from weather sites
curl "https://wttr.in/New_York"
wttr.in is a free weather service that doesn't require an API key and can be used via curl/wget:
# Current weather
curl "https://wttr.in/New_York"
# Compact format
curl "https://wttr.in/New_York?format=3"
# One-line format
curl "https://wttr.in/New_York?format=1"
# JSON format
curl "https://wttr.in/New_York?format=j1"
# Metric units
curl "https://wttr.in/New_York?m"
# Forecast
curl "https://wttr.in/New_York?0"
const https = require('https');
function getWeather(city) {
return new Promise((resolve, reject) => {
const url = `https://wttr.in/${encodeURIComponent(city)}?format=j1`;
https.get(url, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
try {
const weather = JSON.parse(data);
resolve(weather);
} catch (error) {
reject(error);
}
});
}).on('error', reject);
});
}
// Usage
getWeather('New York').then(weather => {
console.log(`Temperature: ${weather.current_condition[0].temp_C}°C`);
console.log(`Condition: ${weather.current_condition[0].weatherDesc[0].value}`);
});
import requests
import json
def get_weather(city):
url = f"https://wttr.in/{city}?format=j1"
response = requests.get(url)
return response.json()
# Usage
weather = get_weather("New York")
current = weather['current_condition'][0]
print(f"Temperature: {current['temp_C']}°C")
print(f"Condition: {current['weatherDesc'][0]['value']}")
# Using offline CSV database
import csv
from datetime import datetime
def get_historical_weather(city, date):
# Assumes you have a local CSV with historical data
with open('weather_database.csv', 'r') as f:
reader = csv.DictReader(f)
for row in reader:
if row['city'] == city and row['date'] == date:
return {
'temperature': row['temp'],
'condition': row['condition'],
'humidity': row['humidity']
}
return None
import requests
def get_us_weather(lat, lon):
# weather.gov is free and doesn't require API key for US locations
url = f"https://api.weather.gov/points/{lat},{lon}"
response = requests.get(url)
data = response.json()
# Get forecast URL
forecast_url = data['properties']['forecast']
forecast = requests.get(forecast_url).json()
return forecast
// weather.json
{
"city": "New York",
"temperature": 72,
"condition": "Sunny",
"humidity": 45,
"updated": "2025-04-30T09:00:00Z"
}
// Parse and display
const fs = require('fs');
const weather = JSON.parse(fs.readFileSync('weather.json', 'utf8'));
console.log(`Weather in ${weather.city}: ${weather.temperature}°F, ${weather.condition}`);
import xml.etree.ElementTree as ET
def parse_weather_xml(file_path):
tree = ET.parse(file_path)
root = tree.getroot()
return {
'city': root.find('city').text,
'temperature': root.find('temperature').text,
'condition': root.find('condition').text
}
# Get weather from system (macOS with Siri)
# Note: This requires user interaction or AppleScript
# Alternative: Use system_profiler
system_profiler SPDisplaysDataType
# Some Linux distributions have weather in the panel
# Extract from system tray using D-Bus (distribution-specific)
# Example for GNOME
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "Main.panel.statusArea.aggregateMenu._weather._item._weatherInfo"
class WeatherCache {
constructor(cacheFile = 'weather_cache.json') {
this.cacheFile = cacheFile;
this.cache = this.loadCache();
}
loadCache() {
try {
const fs = require('fs');
const data = fs.readFileSync(this.cacheFile, 'utf8');
return JSON.parse(data);
} catch {
return {};
}
}
saveCache() {
const fs = require('fs');
fs.writeFileSync(this.cacheFile, JSON.stringify(this.cache, null, 2));
}
get(city) {
const cached = this.cache[city];
if (cached) {
const age = Date.now() - cached.timestamp;
// Cache for 1 hour
if (age < 3600000) {
return cached.data;
}
}
return null;
}
set(city, data) {
this.cache[city] = {
data: data,
timestamp: Date.now()
};
this.saveCache();
}
}
For accurate, real-time weather data, consider these free APIs:
These provide:
#!/bin/bash
CITY="${1:-New York}"
# Try wttr.in first
echo "Fetching weather for $CITY..."
curl -s "https://wttr.in/$CITY?format=3"
# Or try system weather command
if command -v weather &> /dev/null; then
weather "$CITY"
fi
#!/usr/bin/env python3
import sys
import requests
def get_weather(city):
try:
response = requests.get(f"https://wttr.in/{city}?format=j1")
data = response.json()
current = data['current_condition'][0]
area = data['nearest_area'][0]
print(f"Weather in {area['areaName'][0]['value']}, {area['country'][0]['value']}")
print(f"Temperature: {current['temp_C']}°C ({current['temp_F']}°F)")
print(f"Condition: {current['weatherDesc'][0]['value']}")
print(f"Humidity: {current['humidity']}%")
print(f"Wind: {current['windspeedKmph']} km/h")
except Exception as e:
print(f"Error fetching weather: {e}")
if __name__ == '__main__':
city = sys.argv[1] if len(sys.argv) > 1 else "New York"
get_weather(city)