如何在自己的网站上做天气预报?
如何在自己的网站上做天气预报?哪里有这样的接口代码呀? 问题点数:20、回复次数:14Top
1 楼jonas20()回复于 2006-04-05 14:31:29 得分 0
ws.itn168.comTop
2 楼luanwey(大陆响尾蛇)(不做温水里的青蛙王子!))回复于 2006-04-05 15:53:44 得分 0
代码很多。可惜很多失效了。你自己多试几种
Top
3 楼xinyangt(信仰t)回复于 2006-04-05 16:01:11 得分 0
不错的web services 马克一个Top
4 楼chenhaoying(风雨无阻)回复于 2006-04-05 16:25:36 得分 0
<IFRAME ID='ifm1' WIDTH='405' HEIGHT='332' ALIGN='center' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC="http://weather.qq.com/24.htm"></IFRAME>
<iframe id="MainWeatherForecast" name="showWnd" marginWidth="0" marginHeight="0" src="http://www.cmbchina.com/cmb2005web/cmbaspxbin/information/CmbWeatherForecast.aspx" frameBorder="no" width="185" scrolling="no" height="147" style="WIDTH: 185px"></irame>
<iframe name="I1" src="http://weather.qq.com/inc/ss150.htm" width="250" height="240">
</iframe>
<iframe scrolling=no height=288 width=222 frameborder=0 marginHeight=0 marginWidth=0 src=http://minisite.qq.com/Weather/index.html></iframe>
<marquee direction="left" scrollamount="3" scrolldelay="10"><script langusge="javascript" src="http://dw8.cn/2006/tq/?c=海口"></script></marquee>
都是Top
5 楼LinDaXX()回复于 2006-04-05 16:31:21 得分 0
<IFRAME ID='ifm1' WIDTH='405' HEIGHT='332' ALIGN='center' MARGINWIDTH='0' MARGINHEIGHT='0' HSPACE='0' VSPACE='0' FRAMEBORDER='0' SCROLLING='NO' SRC="http://weather.qq.com/24.htm"></IFRAME>
<iframe id="MainWeatherForecast" name="showWnd" marginWidth="0" marginHeight="0" src="http://www.cmbchina.com/cmb2005web/cmbaspxbin/information/CmbWeatherForecast.aspx" frameBorder="no" width="185" scrolling="no" height="147" style="WIDTH: 185px"></irame>
<iframe name="I1" src="http://weather.qq.com/inc/ss150.htm" width="250" height="240">
</iframe>
<iframe scrolling=no height=288 width=222 frameborder=0 marginHeight=0 marginWidth=0 src=http://minisite.qq.com/Weather/index.html></iframe>
<marquee direction="left" scrollamount="3" scrolldelay="10"><script langusge="javascript" src="http://dw8.cn/2006/tq/?c=海口"></script></marquee>
--------------------------------------------
怎么运用的?Top
6 楼chenhaoying(风雨无阻)回复于 2006-04-06 09:28:28 得分 0
你复制代码放到一个.txt文件里,然后把扩展名改为.html,打开就看看就知道了,前提是要能上外网。Top
7 楼lizheng__114(浪淘沙)回复于 2006-04-06 09:35:13 得分 0
顶顶Top
8 楼huangyj(天外飞仙的师傅)回复于 2006-04-06 10:01:50 得分 0
不错,就是上面的这些Top
9 楼rainxiang(楚王好细腰 后宫多饿死)回复于 2006-04-06 10:09:52 得分 0
http://mimg.163.com/tianqi/city/58457.html
抓取下..Top
10 楼pbwf(书生)回复于 2006-04-06 10:16:47 得分 0
可以有很多,有现成的JS代码.我用的是QQ的.上网查一下很多的.
还有通过WEBSERVICES 的.Top
11 楼cow8063(天涯远不远?不远!人在天涯,天涯怎会远)回复于 2006-04-06 10:33:06 得分 0
偷过来的,,不过经常要改Top
12 楼zq9811(自强)回复于 2006-04-06 11:22:29 得分 0
还是写代码抓数据好点Top
13 楼jinran(金然在线)回复于 2006-04-06 11:38:00 得分 0
namespace weather
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;
using System.Text;
/// <summary>
/// show_weather 的摘要说明。
/// </summary>
public class show_weather : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Label radiation;
protected System.Web.UI.WebControls.Label air;
protected System.Web.UI.WebControls.Label wind1;
protected System.Web.UI.WebControls.Label image1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
WebRequest request = WebRequest.Create("http://weather.sina.com.cn/iframe/weather/440301_w.html");
try
{
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
//ContentHtml.Text = sr.ReadToEnd();
string weather1 = sr.ReadToEnd();
// weather1 = weather1.Replace(" ", "");
weather1 = weather1.Replace("\r", "");
weather1 = weather1.Replace("\n", "");
weather1 = weather1.Replace("\t", "");
int start_image,stop_image,start_wind,stop_wind,start_air,stop_air,start_radiation,stop_radiation;
//获取图片相关资料
start_image = weather1.IndexOf("<img",0,weather1.Length);
stop_image = weather1.IndexOf("</td>", start_image) ;
string image2 = weather1.Substring(start_image, stop_image - start_image).Trim();
image2 = image2.Replace("<b>", "");
image2 = image2.Replace("<b class=f16>", "");
image2 = image2.Replace("</b>", "");
image2 = image2.Replace("45", "35");
image1.Text = image2;
//获取城市资料
// start_city = weather1.IndexOf("<b>",0,weather1.Length) + 3;
// stop_city = weather1.IndexOf("</b>", start_city);
// city.Text = weather1.Substring(start_city, stop_city - start_city).Trim();
//获取风力资料
start_wind = weather1.IndexOf("风力",0,weather1.Length) + 3;
stop_wind = weather1.IndexOf("<br>", start_wind);
wind1.Text =weather1.Substring(start_wind, stop_wind - start_wind).Trim();
//获取空气质量资料
start_air = weather1.IndexOf("-->空气质量",0,weather1.Length) + 8;
stop_air = weather1.IndexOf("<br>", start_air);
air.Text = weather1.Substring(start_air, stop_air - start_air).Trim();
//获取紫外外强度资料
start_radiation = weather1.IndexOf("-->紫外线强度",0,weather1.Length) + 9;
stop_radiation = weather1.IndexOf("<br>", start_radiation);
radiation.Text = weather1.Substring(start_radiation, stop_radiation - start_radiation).Trim();
resStream.Close();
sr.Close();
}
catch
{
Response.Write ("对不起,连接超时!");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
Top
14 楼ph580(.Net,我喜欢!www.bjcan.com/hengxing)回复于 2006-04-06 11:46:29 得分 0
www.265.comTop




