zoukankan
html css js c++ java
从中央气象台抓取天气预报
这几天郑州下雪,一直盼望晴天的到来,于是关注天气情况.
可以Google一下:tq 郑州
如今写了个抓取中央气象台的天气预报(
http://www.tq121.com
)
public
string
GetWeather(
string
url)
{
string
weacherhtml
=
String.Empty;
HttpWebRequest rt
=
null
;
HttpWebResponse rs
=
null
;
Stream stream
=
null
;
StreamReader sr
=
null
;
try
{
rt
=
(HttpWebRequest)WebRequest.Create(url);
rs
=
(HttpWebResponse)rt.GetResponse();
stream
=
rs.GetResponseStream();
sr
=
new
StreamReader(stream,System.Text.Encoding.Default);
weacherhtml
=
sr.ReadToEnd();
}
catch
(Exception ee)
{
Response.Write(
"
<script>alert('发生异常')</script>
"
);
}
finally
{
sr.Close();
stream.Close();
rs.Close();
}
int
start
=
weacherhtml.IndexOf(
"
郑州
"
);
int
end
=
weacherhtml.IndexOf(
"
隐私保护
"
);
return
weacherhtml.Substring(start,end
-
start);
}
别的城市天气情况请调用相应的URL,以及修改城市名称.
查看全文
相关阅读:
JavaScript最佳实践
Ionic2学习笔记(3):Pipe
广商14级软件工程分数:第十一回合
Ionic2学习笔记(2):自定义Component
Ionic2学习笔记(1):新建一个页面
Ionic2学习笔记(0):HelloWorld
采用Kettle分页处理大数据量抽取任务
广商14级软件工程分数:第十回合
广商14级软件工程分数:第九回合
广商14级软件工程-项目介绍视频汇总
原文地址:https://www.cnblogs.com/caca/p/81491.html
最新文章
练习题
ajax
jquery取选中值
弹窗
爬虫之数据解析
爬虫之requests模块
python操作excel
会议室预定功能
分配权限
数据分析之练习一
热门文章
stark组件之多级过滤
数据分析之matplotlib.pyplot模块
数据分析之pandas模块
数据分析之numpy模块
Ionic2学习笔记(8):Local Storage& SQLite
Ionic2学习笔记(7):Input
Ionic2学习笔记(6):Navigation
Ionic2学习笔记(5):Provider
广商14级软件工程分数:第十二回合
Ionic2学习笔记(4):*号
Copyright © 2011-2022 走看看