1.网站想调用一个天气预报的代码,请问哪个网站提供免费代码或是天气插件

2.怎么样用vb语言编写 获取当今的天气预报

3.ASP.NET实现天气预报

4.谁帮我找一个天气预报网页代码

5.求~一行天气预报代码(附参考站)

6.如何使用百度天气预报API接口

天气预报代码调用查询_天气预报代码url调用

直接使用插件,如

<iframe width="214" scrolling="no" height="54" frameborder="0" allowtransparency="true" src="://i.tianqi/index.php?c=code&id=42&icon=1&num=3"></iframe>

效果如下

这个插件来源是://.tianqi/plugin/

网站想调用一个天气预报的代码,请问哪个网站提供免费代码或是天气插件

hao123网站左上的天气预报网页代码如下:

<iframe src=

"://.tianqi123/small_page/chengshi_2250.html?

c0=red&c1=D96C00&bg=F4FFF4&w=178&h=20&text=yes"?

width=178 height=21?

marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no?

align=center id=url></iframe>

制作网页时常用的代码有HTML,JaScript,ASP,PHP,CGI等,其中超文本标记语言(标准通用标记语言下的一个应用、外语简称:HTML)是最基础的网页代码。

扩展资料:

网页代码的一些简单使用:

<marquee>...</marquee>普通卷动

<marquee behior=slide>...</marquee>滑动

<marquee behior=scroll>...</marquee>预设卷动

<marquee behior=alternate>...</marquee>来回卷动

<marquee direction=down>...</marquee>向下卷动

<h1>...</h1>标题字(最大 )

<h6>...</h6>标题字(最小)

<b>...</b>粗体字

<strong>...</strong>粗体字(强调)

<br>(换行)

<nobr>...</nobr>水域(不换行)

<p>...</p>水域(段落)

<center>...</center>置中

百度百科-网页代码

怎么样用vb语言编写 获取当今的天气预报

这里的天气预报调用支持DIY样式,并支持IP显示天气,根据用户所在地显示当前天气预报!

://t.xidie/WeatherCode.aspx

样式挺多的。

ASP.NET实现天气预报

首先你想获取当今的天气预报 你发布在网页制作 我姑且是以为你做的是vb.net 网页程序其次 获取当今的天气预报 都是调用各大网站给出的接口 (不会有人自己去整理这些资料的吧)最后 接口的使用 如果是软件 可以调用 WEB服务接口(各网站有) 网页也可以调用这些接口(实现方法输入城市地址,返回天气)还有更简单的 直接使用我给出一个简单框架代码实现:新浪天气预报代码 代码 :://news.sina.cn/iframe/weather/130101.html"></A>

谁帮我找一个天气预报网页代码

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

using System.Net;

using System.IO;

using System.Collections;

/// <summary>

/// Weather 的摘要说明

/// </summary>

public class Weather

{

public Weather()

{

//

// TODO: 在此处添加构造函数逻辑

//

}

public static string ConvertCodeByCity(string City)

{

string Code = "";

switch (City)

{

case "北京":

Code = "110100";

break;

default:

break;

}

return Code;

}

public static ArrayList GetWeather(string code)

{

/*

[0] "北京 "string

[1] "雷阵雨 "string

[2] "9℃" string

[3] "29℃"string

[4] "小于3级"string

*/

string html = "";

try

{

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("://weather.sina.cn/iframe/weather/" + code + "_w.html ");

request.Method = "Get";

//request.Timeout = 1;

request.ContentType = "lication/x--form-urlencoded ";

WebResponse response = request.GetResponse();

Stream s = response.GetResponseStream();

StreamReader sr = new StreamReader(s, System.Text.Encoding.GetEncoding("GB2312"));

html = sr.ReadToEnd();

s.Close();

sr.Close();

}

catch (Exception err)

{

throw new Exception("访问地址出错~~~ ");

}

int count = html.Length;

int starIndex = html.IndexOf("<table ", 0, count);

int endIndex = html.IndexOf("</table>", starIndex, count - starIndex);

html = html.Substring(starIndex, endIndex - starIndex + 8);

//得到城市

int cityStartIndex = html.IndexOf("<b>", 0, html.Length);

int cityEndIndex = html.IndexOf("</b>", 0, html.Length);

string City = html.Substring(cityStartIndex + 3, cityEndIndex - cityStartIndex - 3);

//得到天气

int weatherStartIndex = html.IndexOf("<b>", cityEndIndex);

int weatherEndIndex = html.IndexOf("</b>", weatherStartIndex);

string Weather = html.Substring(weatherStartIndex + 3, weatherEndIndex - weatherStartIndex - 3);

//得到温度

int temperatureStartIndex = html.IndexOf("<b", weatherEndIndex);

int temperatureEndIndex = html.IndexOf("</b>", weatherEndIndex + 3);

string Temperature = html.Substring(temperatureStartIndex + 21, temperatureEndIndex - temperatureStartIndex - 21);

int int1 = Temperature.IndexOf("℃", 0);

int int2 = Temperature.IndexOf("~", 0);

int int3 = Temperature.IndexOf("℃", int2);

string MinTemperature = Temperature.Substring(int2 + 1, int3 - int2);

string MaxTemperature = Temperature.Substring(0, int2 - int1 + 2);

//得到风力

int windforceStartIndex = html.IndexOf("风力:", temperatureEndIndex);

int windforceEndIndex = html.IndexOf("<br>", windforceStartIndex);

string Windforce = html.Substring(windforceStartIndex + 3, windforceEndIndex - windforceStartIndex - 3);

if (Windforce.Contains("小于") && (!Windforce.Contains("等于"))) //判断风力是否含有"小于"或"小于等于"字样将,如果有的话,将其替换为2-

{

//Windforce = Windforce.Replace("小于", "2-");

string strWindforce = Windforce.Substring(2, Windforce.Length - 3);

int minWindforce = Int32.Parse(strWindforce) - 1;

Windforce = Windforce.Replace("小于", minWindforce.ToString() + "-");

}

else if (Windforce.Contains("小于等于"))

{

string strWindforce = Windforce.Substring(4, Windforce.Length - 5);

int minWindforce = Int32.Parse(strWindforce) - 1;

Windforce = Windforce.Replace("小于等于", minWindforce.ToString() + "-");

}

ArrayList al = new ArrayList();

al.Add(City);

al.Add(Weather);

al.Add(MinTemperature);

al.Add(MaxTemperature);

al.Add(Windforce);

return al;

}

}

求~一行天气预报代码(附参考站)

代码如下:

<iframe id=weatherwin border=0 name=weatherwin marginWidth=0 marginHeight=0 src="://weather.369/weather.html" frameBorder=no width=160 scrolling=no height=60></iframe>

也可以用265的代码.在那里上网就显示那里的天气

如何使用百度天气预报API接口

发送到这个网站的一个网址,会自动返回此城市的天气信息。对此信息再格式化就好了。

发送:://main.mapbar/weather.jsp?city=广州

返回:b4.gif^广州^雷阵雨^26℃ ~ 22℃^微风^紫外线:弱

发送:://main.mapbar/weather.jsp?city=上海

返回:b3.gif^上海^阵雨转阴^16℃ ~ 13℃^东南风3-4级^紫外线:最弱

至于如何判断访问者是哪一个城市,需要分析其IP地址然后再加判断吧,你到网上找个IP转城市的数据库看看。

百度API Key申请地址:://lbsyun.baidu/apiconsole/key

创建应用 如图:?

提交后得到API Key 如图:?

接口实例:://api.map.baidu/telematics/v3/weather?location=南昌&output=json&ak=你的API Key&mcode=你的数字签名SHA1;com.example.administrator.jsontest(包名)

接口参数说明

参数类型

参数名称

是否必须

具体描述

String location true 输入城市名或经纬度,城市名如北京或者131,经纬度格式为lng,lat坐标,如:location=116.305145,39.982368;全国值为all,返回省会城市自治区,港澳台天气情况多城市天气预报中间用“|”分隔,如:location=116.305145,39.982368|123.342323,36238945|...

String output false 输出的数据格式,默认为xml格式,当output设置为json时,输出的为json数据格式

String coord_type false 请求参数坐标类型,默认为gcj02经纬度坐标。允许的值为bd09ll、bd09mc、gcj02、wgs84;

返回的JSON数据

{

"error":0,

"status":"success",

"date":"2016-03-05",

"results":[

{

"currentCity":"北京",

"pm25":"144",

"index":[

{

"title":"穿衣",

"zs":"较冷",

"tipt":"穿衣指数",

"des":"建议着厚外套加毛衣等服装。年老体弱者宜着大衣、呢外套加羊毛衫。"},

{

"title":"洗车",

"zs":"不宜",

"tipt":"洗车指数",

"des":"不宜洗车,未来24小时内有扬沙或浮尘,如果在此期间洗车,极易很快蒙上新的灰尘。"},

{

"title":"旅游",

"zs":"一般",

"tipt":"旅游指数",

"des":"风稍大,扬沙或浮尘天气对能见度和空气质量都会有些影响,出行请注意交通安全和取适当的防尘措施。"},

{

"title":"感冒",

"zs":"易发",

"tipt":"感冒指数",

"des":"昼夜温差大,风力较强,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。"},

{

"title":"运动",

"zs":"较不宜",

"tipt":"运动指数",

"des":"有扬沙或浮尘,建议适当停止户外运动,选择在室内进行运动,以避免吸入更多沙尘,有损健康。"},

{

"title":"紫外线强度",

"zs":"最弱",

"tipt":"紫外线强度指数",

"des":"属弱紫外线辐射天气,无需特别防护。若长期在户外,建议涂擦SPF在8-12之间的防晒护肤品。"}

? ],

?"weather_data":[

?{

?"date":"周六 03月05日 (实时:12℃)", ?"dayPictureUrl":"://api.map.baidu/images/weather/day/fuchen.png",

"nightPictureUrl":"://api.map.baidu/images/weather/night/qing.png",

?"weather":"浮尘转晴",

?"wind":"北风4-5级",

?"temperature":"12 ~ -1℃"},

?{

?"date":"周日",

"dayPictureUrl":"://api.map.baidu/images/weather/day/duoyun.png",

"nightPictureUrl":"://api.map.baidu/images/weather/night/duoyun.png",

?"weather":"多云",

?"wind":"微风",

?"temperature":"10 ~ -3℃"},

?{

?"date":"周一", "dayPictureUrl":"://api.map.baidu/images/weather/day/duoyun.png",

"nightPictureUrl":"://api.map.baidu/images/weather/night/yin.png",

?"weather":"多云转阴",

?"wind":"微风",

?"temperature":"13 ~ 2℃"},

?{

?"date":"周二", "dayPictureUrl":"://api.map.baidu/images/weather/day/yin.png",

"nightPictureUrl":"://api.map.baidu/images/weather/night/duoyun.png",

?"weather":"阴转多云",

?"wind":"北风3-4级",

?"temperature":"6 ~ -1℃"}

?]}]}

3. ?我们来写个demo,代码如下:

package com.example.administrator.jsontest;

public class MainActivity extends Activity {

private Button button;

private TextView textView;

private Handler handler = new Handler() {

@Override

public void handleMessage(Message msg) {

switch (msg.what) {

case 0:

String re = (String) msg.obj;

textView.setText(re);

break;

}

}

};

@Override

protected void onCreate(Bundle sedInstanceState) {

super.onCreate(sedInstanceState);

setContentView(R.layout.activity_main);

button = (Button) findViewById(R.id.button);

textView = (TextView) findViewById(R.id.textView);

button.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Log.i("T", "点击了Button");

sendRequestWithHttpClient();

}

});

}

private void sendRequestWithHttpClient() {

new Thread(new Runnable() {

@Override

public void run() {

HttpURLConnection connection = null;

try {

URL url = new URL("://api.map.baidu/telematics/v3/weather?location=南昌&output=json&ak=8ixCCFzlBB617YX7tONI2P5B&mcode=1C:6B:42:33:E8:A6:DC:A2:11:6E:26:EC:84:BD:42:E3:8E:6B:57:9A;com.example.administrator.jsontest");

connection = (HttpURLConnection) url.openConnection();

connection.setRequestMethod("GET");

connection.setConnectTimeout(5000);

connection.setReadTimeout(5000);

InputStream in = connection.getInputStream();

BufferedReader reader = new BufferedReader(new InputStreamReader(in));

StringBuilder response = new StringBuilder();

String line;

while ((line = reader.readLine()) != null) {

response.end(line);

}

Log.i("T", response.toString()); parseJSONObjectOrJSONArray(response.toString());

} catch (MalformedURLException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

}

}).start();

}

//解析JSON数据

private void parseJSONObjectOrJSONArray(String jsonData) {

try {

String count = "";

JSONObject jsonObject = new JSONObject(jsonData);

JSONArray jsonArray = jsonObject.getJSONArray("results");

if (jsonArray.length() > 0) {

JSONObject object = jsonArray.getJSONObject(0);

String city = object.optString("currentCity");

JSONArray array = object.getJSONArray("weather_data");

for (int i = 0; i < array.length(); i++) {

JSONObject jsonObject1 = array.getJSONObject(i);

String dateDay = jsonObject1.optString("date");

String weather = jsonObject1.optString("weather");

String wind = jsonObject1.optString("wind");

String temperature = jsonObject1.optString("temperature");

count =count +"\n"+ dateDay + " " + weather + " " + wind + " " + temperature;

Log.i("AAA",count);

}

Message message = new Message();

message.what = 0;

message.obj = count;

handler.sendMessage(message);

}

} catch (JSONException e) {

e.printStackTrace();

}

}

}

4.?运行结果如下:?