方法1:
天气预报接口(中国天气网)
中国天气weather.com
http://m.weather.com.cn/data/101110101.html(六天预报)
http://www.weather.com.cn/data/sk/101110101.html(实时天气信息)
其中101110101是城市的代码,获得城市代码进入
http://www.weather.com.cn
在搜索框上输入你要需要获得天气的城市,点击查询,即可在地址栏获得相应城市编号,然后替换
http://m.weather.com.cn/data/101110101.html
.Net 抓取页面内容 :
string url = "http://tool.chinaz.com/ip?ip=" + ip;
byte[] b = new WebClient().DownloadData(url);
string str = Encoding.UTF8.GetString(b);
方法2:
右击项目 》添加WEB引用。。。
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
using.....
static void Main(string[] args)
{
WeatherWebService wws = new WeatherWebService();
string[] weatherArray = wws.getWeatherbyCityName("");
Console.WriteLine("{0}-{1}-{2}", weatherArray[6], weatherArray[7], weatherArray[8]);
Console.Read();
}