天气代码html_天气预报代码调用查询
1.如何用js调用天气预报代码 最新
2.VB 怎么实现点击按钮自动获取天气预报
3.怎么样用vb语言编写 获取当今的天气预报
4.网站想调用一个天气预报的代码,请问哪个网站提供免费代码或是天气插件
5.求天气预报代码
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;
}
}
如何用js调用天气预报代码 最新
我现在使用的是这个:
<iframe src="://weather.265/weather.htm" width="160" height="53" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
推荐一下了~~~呵呵
其实,网上也有很多其他的~~
自己找找也可以
VB 怎么实现点击按钮自动获取天气预报
直接使用插件,如
<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/
怎么样用vb语言编写 获取当今的天气预报
为了方便,文本框改成数组控件。代码中用北京作为天气预报地点,改的话将网址改下即可,具体方法可以百度。另外,新浪天气预报只有4天。最后说明一下,除了标签和文本框,没用其它控件。
网站想调用一个天气预报的代码,请问哪个网站提供免费代码或是天气插件
首先你想获取当今的天气预报 你发布在网页制作 我姑且是以为你做的是vb.net 网页程序其次 获取当今的天气预报 都是调用各大网站给出的接口 (不会有人自己去整理这些资料的吧)最后 接口的使用 如果是软件 可以调用 WEB服务接口(各网站有) 网页也可以调用这些接口(实现方法输入城市地址,返回天气)还有更简单的 直接使用我给出一个简单框架代码实现:新浪天气预报代码 代码 :://news.sina.cn/iframe/weather/130101.html"></A>
求天气预报代码
这里的天气预报调用支持DIY样式,并支持IP显示天气,根据用户所在地显示当前天气预报!
://t.xidie/WeatherCode.aspx
样式挺多的。
我的网站用的代码:://jj.infocom.cn酒嘉市场信息网
这是泰安的天气预报代码,看你需要那种样式
样式一代码:<iframe src="://.tianqi123/small_page/chengshi_1632.html" width=178 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_1632.html?c0=F9DC68&c1=white&c2=FEFCE0&t1=red&bg=white&w=178&text=no" width=178 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_1632.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语言,您还可以在iframe代码中的url后面加参数,如:
chengshi_321.html?c0=F9DC68&c1=white&c2=FEFCE0&t1=red&bg=white&w=178&h=250&text=no
其中 c0 表示 表格第一行背景颜色,c1,c2表示表格其他行间隔的背景颜色,t1表示 标题颜色,bg 表示页面北京颜色,w表示表格宽度 h 表示表格高度
当 text=yes 时,将会出现滚动的天气文字,建议您自己调试看看,如:
chengshi_321.html?c0=red&c1=FF9900&bg=F4FFF4&w=178&h=20&text=yes
注意:颜色请不要加 # 符号,如 #FF9900 请写成 FF9900
欢迎访问我的网站
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。