您现在的位置是: 首页 > 天气资讯 天气资讯

天气预报代码调用_.net天气预报代码

tamoadmin 2024-08-30 人已围观

简介1.天气预报web服务2.天气预报HTML代码求助3.如何使用百度天气预报API接口4.在自己的网站,添加一个天气预报5.柯林程序如何加调天气全国代码6.hao123网站左上的天气预报网页代码是什么?在添加天气预报之前,你得先添加(自定义面板),然后输入标题,勾选(显示源代码),在空白面板里粘贴如下代码,另外需要注意的是,代码显示可能不是你想要的城市,那么你就需要修改为你的城市的代码。 几段超酷实

1.天气预报web服务

2.天气预报HTML代码求助

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

4.在自己的网站,添加一个天气预报

5.柯林程序如何加调天气全国代码

6.hao123网站左上的天气预报网页代码是什么?

天气预报代码调用_.net天气预报代码

在添加天气预报之前,你得先添加(自定义面板),然后输入标题,勾选(显示源代码),在空白面板里粘贴如下代码,另外需要注意的是,代码显示可能不是你想要的城市,那么你就需要修改为你的城市的代码。

几段超酷实用的天气预报代码,整理如下:

第一种:

<iframe src=://weather.265/weather.htm width="160" height="54" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>

效果: <IFRAME ID='ifm2' WIDTH='189' HEIGHT='190' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC='://weather.qq/inc/ss258.htm'></IFRAME>

效果: 使用方法:以上显示的是九江的天气预报,你可以改成你自己的,打开页面:://weather.qq,在右边的框中

选择你所在的城市(比如选择南京),然后打开了这个页面:://weather.qq/preend.htm?dc244.htm,然后将网址中的244替换'://weather.qq/inc/ss258.htm'中的258,那么最后显示出来的就是南京的天气预报。

第三种:

<IFRAME ID='ifm2' WIDTH='260' HEIGHT='70' ALIGN='CENTER' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' src="://news.sina.cn/iframe/weather/130101.html"></ifreame>

效果:

第四种:

<iframe width="469" height="218" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src=://news.qq/cgi-bin/news_weather_search?city=贵阳 allowTransparency="true"></iframe>

效果:

第五种:

<IFRAME ID='ifm1' WIDTH='405' HEIGHT='332' ALIGN='center' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC="://weather.qq/24.htm"></IFRAME>

效果:

第六种:

<iframe width="145" height="130" border="0" align="center" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" src="://minisite.qq/Weather/news_new.html" allowTransparency="true"></iframe>

效果:

第七种:

以前很流行的一段代码(在Google上搜到的90%都是这一段),现在已经不能用了,特此写出来,以免大家浪费精力:

<iframe width="150" height="240" frameborder="0" scrolling="No" src='://news.qq/cgi-bin/news_qq_search?city=xxx'></iframe>

其中的“xxx”是每个城市的代码:比如武汉的就是%CE%E4%BA%BA

下面是其他的一些城市的编码:

上海-%C9%CF%BA%A3

北京-%B1%B1%BE%A9

青岛-%C7%E0%B5%BA

济南-%BC%C3%C4%CF

武汉-%CE%E4%BA%BA

福州-%B8%A3%D6%DD

以下得到其他城市的代码的方法:

baidu搜索一下城市的名称,比如"重庆",然后地址栏中的那个代码就是了这些中文字符如何编码变成%D6%D8%C7%EC这种的。比如得到的网址是:

://.baidu/s?wd=%D6%D8%C7%EC

后面的%D6%D8%C7%EC即是。

现在我给大家推荐一个专门提供天气预报和免费天气预报代码服务的网站:

天气123:中国城市天气预报(://.tianqi123/)

只要复制粘贴该网站提供的代码就可以了。

如下是3款(南京)效果图:

第八种:

<iframe src="://.tianqi123/small_page/chengshi_1189.html" width=160 height=248 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no align=center id=url></iframe>

第九种:

<iframe src="://.tianqi123/small_page/chengshi_1189.html?c0=F9DC68&c1=white&c2=FEFCE0&t1=red&bg=white&w=160&text=no" width=160 height=248 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no align=center id=url></iframe>

第十种:

<iframe src="://.tianqi123/small_page/chengshi_1189.html?c0=red&c1=FF9900&bg=F4FFF4&w=160&h=20&text=yes" width=160 height=21 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no align=center id=url></iframe>

该天气代码高级使用方法:

如果您会HTML语言,您还可以在iframe代码中的url后面加参数,如:

chengshi_321.html?c0=F9DC68&c1=white&c2=FEFCE0&t1=red&bg=white&w=160&h=250&text=no

其中 c0 表示表格第一行背景颜色,c1,c2表示表格其他行间隔的背景颜色,t1表示标题颜色,bg 表示页面北京颜色,w表示表格宽度 h 表示表格高度

当 text=yes 时,将会出现滚动的天气文字,建议您自己调试看看,如:

chengshi_321.htmlc0=red&c1=FF9900&bg=F4FFF4&w=160&h=20&text=yes

注意:颜色请不要加 # 符号,如 #FF9900 请写成 FF9900

````我的BLOG教程里面的东西 如果看着很烦琐 欢迎去我的BLOG 仔细研究

天气预报web服务

简单的方法,可以直接在servlet的doGet或doPost里面构建这个xml,然后写回响应就可以了。

需要搭建ja应用服务器如tomcat服务器,运行这个servlet就可以。

xml的构建对于Ja来说工具很多,JDOM, Dom4J等。

如果客户端要求用web service方式提供,就考虑Apache CXF这些Ja Web服务框架,不过一般没必要的。

天气预报HTML代码求助

首先你在你的web项目下面的References,右击References,点击Add Web

Refercenes 然后把://webservice.webxml.cn/WebServices/WeatherWS.asmx地址输入到URl文本框后面,然后点击后面的绿色箭头,再点击添加按钮,此时在web项目里会出现Web Refercens下面会出现一个命名空间,此命名空间里就是web服务里所包含类,然后你在一个页面上添加一个测试按钮,在按钮里写如下代码: cn.webxml.webservice.WeatherWS wws = new cn.webxml.webservice.WeatherWS();

string[] data= wws.getWeather("上海","");

data数组里就是关于上海城市的天气情况的数据,然后你根据实际情况做处理即可

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

<iframe width="420" scrolling="no" height="60" frameborder="0" allowtransparency="true" src="://i.tianqi/index.php?c=code&id=12&icon=1&num=5"></iframe>

绝对管用 样式可以调整 有不懂的可以问我

在自己的网站,添加一个天气预报

百度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.?运行结果如下:?

柯林程序如何加调天气全国代码

非常简单哦,如你想使用 ://.sougou中的天气服务,你可以在右键快捷菜单中通过查看源文件,你会发现有这样一段<iframe id="weather" src="" frameborder="0" scrolling="no" width="70" height="60" allowtransparency="true"></iframe>是放置天气信息的内嵌页,继续查找weather可以发现有这样一段var wurl = "weather/new"+cityCode+".html?_t=" + new Date().getTime();这段是用Ajax方法获取当前天气信息,"?_t"是传递时间参数,加一个时间戳,可以防止从缓存中读取页面,而造成信息不准确。其中的cityCode显然是城市代码了,在var validCity=['CN1101','CN1201','CN1301','CN1302','CN1303','CN1304','CN1305','CN1306','CN1307','CN1308','CN1309','CN1310','CN1311','CN1401','CN1402','CN1403','CN1404','CN1405','CN1406','CN1407','CN1408','CN1409','CN1410','CN1501','CN1502','CN1503','CN1504','CN1505','CN1506','CN1521','CN1525','CN152……里面定义的,其中CN1101显然是北京了,其他的自己去测试获取哦。说得更简单点就是使用别人的天气服务把那段获取天气信息的代码附到自己的页面后台代码中就可以了。

hao123网站左上的天气预报网页代码是什么?

您好,柯林程序的天气预报调用UBB为:天气预报:[tq=X]默认地区的区号[/tq] (X=0时全显示,X=1时不显示当前温度,X=2时变三行显示) 详细的请参考: ://188ch/admin/ubb2.aspx

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>置中

百度百科-网页代码