【转】AS3多种天气预报调用代码分享

今天我们来介绍利用weather.com.cn上的天气预报功能,这里介绍了大家常用的,其它的大家可以自己去下载。
我们这里的天气预览不需要js来调用,只要用iframe就可以了,更不需要ASP/' target='_blank'class='infotextkey'>asp.net之类的来操作了。

http://m.weather.com.cn/m/pn1/weather.htm
" width="235" height="20" marginwidth="0" marginheight="0"hspace="0" vspace="0"
frameborder="0" scrolling="no">


调用代码二

  1.  
  2. " width="180"height="20" marginwidth="0" marginheight="0" hspace="0"vspace="0" 
  3. frameborder="0"scrolling="no">
复制代码

调用代码三

  1.  
  2. " width="225"height="20" marginwidth="0" marginheight="0" hspace="0"vspace="0" 
  3. frameborder="0"scrolling="no">
复制代码

调用代码四

  1.  
  2. " width="160"height="20" marginwidth="0" marginheight="0" hspace="0"vspace="0" 
  3. frameborder="0"scrolling="no">
复制代码


原文链接:  http://www.002pc.com/master/College/26996.html

 

转载于:https://www.cnblogs.com/seanp/p/6522087.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Spring Boot和FeignClient调用天气预报接口的示例代码: 首先,在pom.xml文件中添加以下依赖: ```xml <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> ``` 然后,在应用程序主类上添加@EnableFeignClients注解,启用FeignClient: ```java @SpringBootApplication @EnableFeignClients public class WeatherApplication { public static void main(String[] args) { SpringApplication.run(WeatherApplication.class, args); } } ``` 接下来,创建一个FeignClient接口来定义调用天气预报API的方法: ```java @FeignClient(name = "weather-api", url = "https://api.weather.com") public interface WeatherApiClient { @GetMapping("/forecast") ResponseEntity<String> getForecast(@RequestParam("city") String city, @RequestParam("apiKey") String apiKey); } ``` 在这个接口上,使用了FeignClient注解来指定要调用的API的名称和URL。然后,定义了一个getForecast方法,它使用@GetMapping注解来指定调用API的HTTP方法和路径,并使用@RequestParam注解来指定必需的查询参数。这个方法返回一个ResponseEntity<String>,其中包含API响应的主体。 最后,在需要调用天气预报API的代码中,注入WeatherApiClient接口,并调用getForecast方法: ```java @RestController public class WeatherController { @Autowired private WeatherApiClient weatherApiClient; @GetMapping("/weather") public ResponseEntity<String> getWeather(@RequestParam("city") String city, @RequestParam("apiKey") String apiKey) { return weatherApiClient.getForecast(city, apiKey); } } ``` 在这个控制器中,注入了WeatherApiClient接口,并在getWeather方法中调用了getForecast方法来获取天气预报数据。这个方法返回了一个ResponseEntity<String>,它包含了API响应的主体。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值