首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏京程一灯

    用 Node.js 的 16 行代码创建一个简单的天气 App

    在本教程中,您将学习如何调 用 OpenWeatherMap.org API 并把结果输出到控制台。 - 20 秒快速注册 OpenWeatherMap.org 账户。 如果这样的项目你感兴趣并且你也在寻找 Node 更深入的教程请查看另一篇文章 Top Three Node.js courses 第一步:OpenWeatherMap ? 当你想玩玩 API ,OpenWeatherMap 是一个不错的地方。实际上有关于天气的11种不同的api供您访问。 通过阅读OpenWeatherMap(https://openweathermap.org/current) 文档,能够确定 url 是什么。 程序没有错,OpenWeatherMap 默认返回 Kelvin 温度。如果需要华氏温度添加参数 units=imperial。

    2.4K30发布于 2019-03-28
  • 来自专栏大数据,java,Python和前端

    AI 辅助开发实战:从零构建智能天气通知系统

    AI提供的帮助:ChatGPT建议使用Node.js作为后端语言,Express框架提供API接口,node-cron处理定时任务,OpenWeatherMap API获取天气数据,并提供了以下架构方案 阶段二:核心代码实现协作场景:代码生成和实现使用Cursor Editor,我通过以下指令生成天气服务的基础代码:// 使用Cursor的AI功能生成代码// 创建一个WeatherService类,使用OpenWeatherMap 我向Cursor指出这个问题:这个代码有问题,OpenWeatherMap API不直接提供rainProbability字段。 、通知服务和用户服务分离AI提供的重构建议:使用依赖注入模式解耦各个服务提取配置到单独的文件中添加JSDoc注释提高代码可读性创建工厂函数便于测试// 重构后的天气服务类/** * 天气服务类,负责与OpenWeatherMap API交互 * @class */class WeatherService { /** * 创建天气服务实例 * @param {string} apiKey - OpenWeatherMap

    28910编辑于 2025-08-27
  • 来自专栏freesan44

    用GCD线程组与GCD信号量将异步线程转换为同步线程

    getNetworkingData{17NSString *appIdKey =@"8781e4ef1c73ff20a180d3d7a42a8c04";18NSString* urlString_1 =@"http://api.openweathermap.org /data/2.5/weather";19NSString* urlString_2 =@"http://api.openweathermap.org/data/2.5/forecast/daily"; getNetworkingData{17NSString *appIdKey =@"8781e4ef1c73ff20a180d3d7a42a8c04";18NSString* urlString_1 =@"http://api.openweathermap.org /data/2.5/weather";19NSString* urlString_2 =@"http://api.openweathermap.org/data/2.5/forecast/daily"; /data/2.5/weather";19NSString* urlString_2 =@"http://api.openweathermap.org/data/2.5/forecast/daily";

    75520发布于 2018-09-05
  • 来自专栏Golang语言社区

    从零开始创建一个基于Go语言的web service

    Beijing" } 201 Created GET /location 200 OK ["Shanghai", "Beijing"] ### GET /location/{name} 查询openweathermap.com ,返回结果,因为天气数据更新不频繁,可缓存在数据库中,保留1个小时 不需要考虑查询openweathermap.com返回错误的情况 例子5 GET /location/Shanghai 200 } ] } ### DELETE /location/{name} 例子6 DELETE /location/Shanghai 200 OK 而根据以上描述,要调用openweathermap.com 网站的Restful API,具体的调用方式如下: curl "api.openweathermap.org/data/2.5/weather? weatherTable string = "city_weather" const timeoutSet int64 = 3600 const OpenWeatherURL string = "http://api.openweathermap.org

    2.3K90发布于 2018-03-20
  • 来自专栏小码农薛尧

    介绍一款漂亮强大的导航应用,初次使用HomePage

    text_size: md format: dateStyle: short timeStyle: short hourCycle: h23 # 地图插件 - openweathermap longitude: 120.59 #经纬度 units: metric apiKey: ****** #注册并获取API密钥,访问OpenWeatherMap row columns: 3 标签: #icon: bq.png #可以加图标 style: row columns: 7 providers: openweathermap

    10710编辑于 2026-01-22
  • 【智能体-获取当前位置的天气和景点信息】

    (error) => { console.error("Error getting location:", error.message); } ); 查询天气信息 调用天气API(如OpenWeatherMap 示例代码: const API_KEY = "your_api_key"; fetch(`https://api.openweathermap.org/data/2.5/weather?

    20110编辑于 2025-12-18
  • 来自专栏linux百科小宇宙

    使用Vue构建桌面应用程序:Vuido

    我们将使用OpenWeatherMap API获取真实数据。 如果你想查阅完整的代码,请点击这里。 安装 正如Vuido文档所述,要开发桌面应用程序有些预先条件。 我使用OpenWeatherMap API来获取天气数据。它提供了很多内容,但我们只需要Current weather data这一部分。你可以在这里测试JSON响应示例。 所以,要想获得数据,我需要添加axios库: npm install --save axios 然后导入它,设置好base URL和OpenWeatherMap API key变量 : import axios from 'axios'; axios.defaults.baseURL = 'http://api.openweathermap.org/data

    1.8K00发布于 2021-06-06
  • 来自专栏前端达人

    使用 Vanilla JavaScript 框架创建一个简单的天气应用

    这样的API市面上比较多,比如阿里云市场就可以申请,不过好像是收费的,调用起来还需要后端配合,为了让大家快速上手,我推荐大家去国外 https://openweathermap.org/ 这个网站申请一个免费的 2、执行 AJAX 请求 假设第一次进入页面,城市列别还没相关信息,这种情况我们只需要发送 OpenWeatherMap 的 API 请求即可,遵循 API 文档,我们只需要传递申请的 API 的 key const url = `https://api.openweathermap.org/data/2.5/weather? 以下接口自带的几种图片我们需要一一对应成我们自己个性化的图标,名称也保持一致,放到我们的图片文件夹即可: 对应代码需要做相应的修改,如下所示: //BEFORE const icon = `https://openweathermap.org input.focus(); return; } } //ajax here const url=`https://api.openweathermap.org

    2.3K30发布于 2020-02-27
  • 来自专栏小二十七

    OpenAPI 3.0 规范-食用指南

    Demo description: "This is an API program for teaching" version: '1.1' termsOfService: "https://openweathermap.org 来对目前文档进行补充,例如你可以在根目录添加该属性,如下: externalDocs: description: externalDocs API Documentation url: https://openweathermap.org all pets externalDocs: description: externalDocs API Documentation url: https://openweathermap.org 规范的文件的使用说明 参考资料: OpenAPI tutorial using Swagger Editor and Swagger UI: Overview OpenAPI 不错的教程 OpenApi Openweathermap

    15.3K31编辑于 2022-11-11
  • 来自专栏前端达人

    使用 Vanilla JavaScript 框架创建一个简单的天气应用

    这样的API市面上比较多,比如阿里云市场就可以申请,不过好像是收费的,调用起来还需要后端配合,为了让大家快速上手,我推荐大家去国外 https://openweathermap.org/ 这个网站申请一个免费的 2、执行 AJAX 请求 假设第一次进入页面,城市列别还没相关信息,这种情况我们只需要发送 OpenWeatherMap 的 API 请求即可,遵循 API 文档,我们只需要传递申请的 API 的 key const url = `https://api.openweathermap.org/data/2.5/weather? 对应代码需要做相应的修改,如下所示: //BEFORE const icon = `https://openweathermap.org/img/wn/${ weather[0]["icon"] } input.focus(); return; } } //ajax here const url=`https://api.openweathermap.org

    2.3K20发布于 2020-03-13
  • 来自专栏气象杂货铺

    天气和气象数据网站集合,以及.nc数据的打开方法

    2.实时天气数据 国外权威网站openweathermap 网址https://openweathermap.org/ 通过申请api使用,最好用的是它的天气地图 ?

    11.8K50发布于 2020-05-26
  • 来自专栏CDN及云技术分享

    用Python实现可视化天气预报

    pen.rt(angle) pen.pendown() pen.fd(second_hand)二、未来12小时天气获取未来12小时天气预报这个update_forecast函数,我们通过拉取openweathermap def update_forecast(): global hour_cursor # weather ID breakdown https://openweathermap.org/weather-conditions wind_speed"] # 风速 id_array[num] = data["hourly"][num]["weather"][0]["id"] # 天气icon id,见https://openweathermap.org

    50410编辑于 2024-03-15
  • 来自专栏机器之心

    放弃Python转向Go语言:我们找到了以下9大理由

    原因 3:开发者效率&不要过于创新 看一下绝佳的入门教程《开始学习 Go 语言》(http://howistart.org/posts/go/1/)中的一小段代码: package main type openWeatherMap struct{}func (w openWeatherMap) temperature(city string) (float64, error) { resp, err := http.Get ("http://api.openweathermap.org/data/2.5/weather? = nil { return 0, err } log.Printf("openWeatherMap: %s: %.2f", city, d.Main.Kelvin)

    2.1K110发布于 2018-05-08
  • 来自专栏数据派THU

    放弃Python转向Go语言:这9大理由就够了 !(附代码)

    3:开发者效率&不要过于创新 看一下绝佳的入门教程《开始学习 Go 语言》(http://howistart.org/posts/go/1/)中的一小段代码: package main type openWeatherMap struct {}func (w openWeatherMap) temperature(city string) (float64, error) { resp, err := http Get ( "http://api.openweathermap.org/data/2.5/weather? Printf ( "openWeatherMap: %s: %.2f" , city, d. Main . Kelvin ) return d. Main .

    2.6K120发布于 2018-03-26
  • 来自专栏程序员

    纯小白入门:手把手教你实现第一个MCP服务器

    我们将使用OpenWeatherMap的API作为数据源(你需要先免费注册获取API key)。 在app = Server("weather-server")后添加以下代码:import aiohttpfrom mcp.server.models import ToolResult# 你的OpenWeatherMap """ # 构建请求URL url = f"http://api.openweathermap.org/data/2.5/weather?

    2.8K20编辑于 2025-09-22
  • 来自专栏Web大前端

    Flutter for Web:跨平台移动与Web开发的新篇章

    Future<void> fetchWeather(String city) async {   final response = await http.get(Uri.parse('https://api.openweathermap.org 实现天气数据获取 接下来,在_WeatherPageState类中实现_fetchWeather方法,使用http库从OpenWeatherMap API获取天气数据。 String _weatherApiUrl = 'https://api.openweathermap.org/data/2.5/weather? setState(() {         _weatherInfo = 'Error: $e';       });     }   }   // ... } 请注意替换YOUR_API_KEY为你自己的OpenWeatherMap cityName = value; }); }, ), 然后在_fetchWeather方法中使用输入的城市名: String _weatherApiUrl = 'https://api.openweathermap.org

    1.8K10编辑于 2024-06-13
  • 来自专栏信数据得永生

    Python 自动化指南(繁琐工作自动化)第二版:十六、使用 CSV 文件和 JSON 数据

    然后在你的浏览器中访问openweathermap.org/api并注册一个免费帐户,以获得一个 API 密钥,也称为应用 ID,对于 OpenWeatherMap 服务来说,它是一个类似于'30144aba38018987d84710d0e319281e OpenWeatherMap 服务要求查询格式为城市名、逗号和两个字母的国家代码(如“US”代表美国)。 第二步:下载 JSON 数据 OpenWeatherMap.org以 JSON 格式提供实时天气信息。首先你必须在网站上注册一个免费的 API 密匙。 您的程序只需下载位于api.openweathermap.org/data/2.5/forecast/daily? --snip-- # Download the JSON data from OpenWeatherMap.org's API. url ='https://api.openweathermap.org

    15.6K40编辑于 2023-04-04
  • 来自专栏flutter开发精选

    flutter架构:Repository设计模式

    「Repository设计模式在实际中的使用」 我们以OpenWeatherMap(https://openweathermap.org/api)提供的天气查询API为例,做一个简单的天气查询APP。 我们先看看API 文档(https://openweathermap.org/current),先了解需要如何调用 API,以及响应数据的JSON 格式。

    3.5K30编辑于 2022-09-20
  • 来自专栏互扯程序

    从 Python 切换到 Go 的 9 个理由

    type openWeatherMap struct{} func (w openWeatherMap) temperature(city string) (float64, error) { resp , err := http.Get("http://api.openweathermap.org/data/2.5/weather? = nil { return 0, err } log.Printf("openWeatherMap: %s: %.2f", city, d.Main.Kelvin)

    1.6K20发布于 2020-05-22
  • Retrofit入门:打造Android类型安全的HTTP客户端

    假设我们要构建一个简单的天气应用,使用OpenWeatherMap API:1. 创建Retrofit实例并使用```javaprivate static final String BASE_URL = "https://api.openweathermap.org/data/2.5

    27610编辑于 2025-10-04
领券