#
#########################################################
# use the webservice provided by www.xview.com.cn
# get the weather forcast
import httplib, urllib
url = ' www.xview.com.cn '
para = url.urlencode({ ' cityName ' : ' 北京 ' })
headers = { ' Content-Type ' : ' application/x-www-form-urlencoded ' }
conn = httplib.HTTPConnection(url)
conn.request( ' POST ' , ' /WebService/Weather.asmx/GetWeatherDataSet ' , para, headers)
resp = conn.getresponse()
res_xml = ''
if resp.status != 200 :
print ' ERROR '
else :
res_xml = resp.read()
conn.close()
print res_xml
# use the webservice provided by www.xview.com.cn
# get the weather forcast
import httplib, urllib
url = ' www.xview.com.cn '
para = url.urlencode({ ' cityName ' : ' 北京 ' })
headers = { ' Content-Type ' : ' application/x-www-form-urlencoded ' }
conn = httplib.HTTPConnection(url)
conn.request( ' POST ' , ' /WebService/Weather.asmx/GetWeatherDataSet ' , para, headers)
resp = conn.getresponse()
res_xml = ''
if resp.status != 200 :
print ' ERROR '
else :
res_xml = resp.read()
conn.close()
print res_xml
#
######################################################
# use the webservice proivded by www.webserivcex.net
# get the weahter of now (not weather forcast)
import httplib
url = ' www.webservicex.net '
conn = httplib.HTTPConnection(url)
conn.request( ' GET ' , ' /globalweather.asmx/GetWeather?CityName=Beijing&CountryName=china ' )
resp = conn.getresponse()
if resp.status = 200 :
print resp.read()
else :
print ‘ERROR’
conn.close()
# use the webservice proivded by www.webserivcex.net
# get the weahter of now (not weather forcast)
import httplib
url = ' www.webservicex.net '
conn = httplib.HTTPConnection(url)
conn.request( ' GET ' , ' /globalweather.asmx/GetWeather?CityName=Beijing&CountryName=china ' )
resp = conn.getresponse()
if resp.status = 200 :
print resp.read()
else :
print ‘ERROR’
conn.close()