C 獲取中國天氣網免費天氣預報資訊

2021-07-30 07:21:38 字數 1978 閱讀 1912

中國天氣網介面位址:」 + weathercitycode(為城市code);

獲取的資訊為xml資料,所以在使用前我們可以將它轉化成字串,之後在序列化成天氣類;

string weatherinfourl = "" + weathercitycode;

string weatherstr = gethtml2(weatherinfourl);

resp tempinfo = xmldeseralizer(weatherstr);

————轉化過程中需要用到的方法—————–

}—————-天氣實體類———————-

using system;

using system.collections.generic;

using system.linq;

using system.text;

namespace soian.zhitai.models.weatherforecast

public

string updatetime

public

string wendu

public

string fengli

public

string shidu

public

string fengxiang

public environment environment

public alarm alarm

public listforecast

}public

class environment

public

string pm25

public

string suggest

public

string quality

public

string majorpollutants

public

string time

}public

class alarm

public

string alarmtype

public

string alarmdegree

public

string alarmtext

public

string alarm_details

public

string standard

public

string suggest

}public

class weather

public

string high

public

string low

public climate day

public climate night

}public

class climate

public

string fengxiang

public

string fengli }}

Google API 獲取天氣預報資訊

要獲得天氣預報資訊可用利用google提供的藉口,城市名稱 拼音 它將返回乙個用xml封裝的天氣資訊。示例 shanghai 返回 xml version 1.0 xml api reply version 1 weather module id 0 tab id 0 mobile row 0 mo...

Google API 獲取天氣預報資訊

要獲得天氣預報資訊可用利用google提供的藉口,城市名稱 拼音 它將返回乙個用xml封裝的天氣資訊。示例 shanghai 返回 xml version 1.0 xml api reply version 1 weather module id 0 tab id 0 mobile row 0 mo...

獲取各地天氣預報資訊

出門旅遊時,或是在一些手機流量耗盡 無法上網的時候,可通過在臨走時定製一些天氣資訊,來傳送!主要是通過linux cron fetion api 網頁解析 提供天氣資訊的 1.m.sohu.com 有乙個city引數,傳入encode 北京 來查詢當天的天氣,做相應解析即可 2.這需要乙個它所定義的...