天气API、Python或JavaScript

天气API、Python或JavaScript,python,django,weather-api,Python,Django,Weather Api,我正在努力使天气API正常工作。但我如何才能得到C°和天气图标;没有其他功能吗?一旦安装了pip,打开一个ipython shell,探索pywapi可以做什么。下面是一个实际为您提供所需内容的示例:- In [1]: import pywapi In [2]: pywapi. pywapi.GOOGLE_CITIES_URL pywapi.YAHOO_WEATHER_URL pywapi.get_weather_from

我正在努力使天气API正常工作。但我如何才能得到C°和天气图标;没有其他功能吗?

一旦安装了pip,打开一个ipython shell,探索
pywapi
可以做什么。下面是一个实际为您提供所需内容的示例:-

In [1]: import pywapi

In [2]: pywapi.
pywapi.GOOGLE_CITIES_URL                   pywapi.YAHOO_WEATHER_URL                   pywapi.get_weather_from_weather_com        pywapi.urlopen
pywapi.GOOGLE_COUNTRIES_URL                pywapi.getText                             pywapi.get_weather_from_yahoo              pywapi.wind_beaufort_scale
pywapi.NOAA_WEATHER_URL                    pywapi.get_cities_from_google              pywapi.minidom                             pywapi.wind_direction
pywapi.URLError                            pywapi.get_countries_from_google           pywapi.quote                               pywapi.xml_get_attrs
pywapi.WEATHER_COM_URL                     pywapi.get_everything_from_yahoo           pywapi.re                                  pywapi.xml_get_ns_yahoo_tag
pywapi.YAHOO_WEATHER_NS                    pywapi.get_weather_from_noaa               pywapi.sys                                 pywapi.yield_all_country_city_codes_yahoo

In [2]: pywapi.get_weather_from_yahoo?
Type:       function
String Form:<function get_weather_from_yahoo at 0x10daeb9b0>
File:       /Users/calvin/.virtualenvs/myweather/lib/python2.7/site-packages/pywapi.py
Definition: pywapi.get_weather_from_yahoo(location_id, units='metric')
Docstring:
Fetches weather report from Yahoo! Weather

Parameters:
  location_id: A five digit US zip code or location ID. To find your location ID,
  browse or search for your city from the Yahoo! Weather home page (http://weather.yahoo.com/)
  The weather ID is in the URL for the forecast page for that city. You can also get
  the location ID by entering your zip code on the home page. For example, if you
  search for Los Angeles on the Weather home page, the forecast page for that city
  is http://weather.yahoo.com/forecast/USCA0638.html. The location ID is USCA0638.

  units: type of units. 'metric' for metric and '' for non-metric
  Note that choosing metric units changes all the weather units to metric,
  for example, wind speed will be reported as kilometers per hour and
  barometric pressure as millibars.

Returns:
  weather_data: a dictionary of weather data that exists in XML feed.
  See http://developer.yahoo.com/weather/#channel

In [3]: pywapi.get_weather_from_yahoo('USCA0638')
Out[3]:
{'astronomy': {'sunrise': u'6:16 am', 'sunset': u'7:28 pm'},
 'atmosphere': {'humidity': u'67',
  'pressure': u'1013.7',
  'rising': u'1',
  'visibility': u'16.09'},
 'condition': {'code': u'33',
  'date': u'Sat, 20 Apr 2013 9:46 pm PDT',
  'temp': u'18',
  'text': u'Fair',
  'title': u'Conditions for Los Angeles, CA at 9:46 pm PDT'},
 'forecasts': [{'code': u'31',
   'date': u'20 Apr 2013',
   'day': u'Sat',
   'high': u'26',
   'low': u'15',
   'text': u'Clear'},
  {'code': u'32',
   'date': u'21 Apr 2013',
   'day': u'Sun',
   'high': u'26',
   'low': u'14',
   'text': u'Sunny'},
  {'code': u'34',
   'date': u'22 Apr 2013',
   'day': u'Mon',
   'high': u'22',
   'low': u'13',
   'text': u'Mostly Sunny'},
  {'code': u'30',
   'date': u'23 Apr 2013',
   'day': u'Tue',
   'high': u'21',
   'low': u'14',
   'text': u'Partly Cloudy'},
  {'code': u'30',
   'date': u'24 Apr 2013',
   'day': u'Wed',
   'high': u'19',
   'low': u'13',
   'text': u'Partly Cloudy'}],
 'geo': {'lat': u'34.05', 'long': u'-118.23'},
 'html_description': u'\n[![][5]][5]<br />\n<b>Current Conditions:</b><br />\nFair, 18 C<BR />\n<BR /><b>Forecast:</b><BR />\nSat - Clear. High: 26 Low: 15<br />\nSun - Sunny. High: 26 Low: 14<br />\nMon - Mostly Sunny. High: 22 Low: 13<br />\nTue - Partly Cloudy. High: 21 Low: 14<br />\nWed - Partly Cloudy. High: 19 Low: 13<br />\n<br />\n<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>\n',
 'link': u'http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_c.html',
 'location': {'city': u'Los Angeles', 'country': u'US', 'region': u'CA'},
 'title': u'Yahoo! Weather - Los Angeles, CA',
 'units': {'distance': u'km',
  'pressure': u'mb',
  'speed': u'km/h',
  'temperature': u'C'},
 'wind': {'chill': u'18', 'direction': u'0', 'speed': u'0'}}
安装了pip后,打开ipython shell并探索
pywapi
可以做什么。下面是一个实际为您提供所需内容的示例:-

In [1]: import pywapi

In [2]: pywapi.
pywapi.GOOGLE_CITIES_URL                   pywapi.YAHOO_WEATHER_URL                   pywapi.get_weather_from_weather_com        pywapi.urlopen
pywapi.GOOGLE_COUNTRIES_URL                pywapi.getText                             pywapi.get_weather_from_yahoo              pywapi.wind_beaufort_scale
pywapi.NOAA_WEATHER_URL                    pywapi.get_cities_from_google              pywapi.minidom                             pywapi.wind_direction
pywapi.URLError                            pywapi.get_countries_from_google           pywapi.quote                               pywapi.xml_get_attrs
pywapi.WEATHER_COM_URL                     pywapi.get_everything_from_yahoo           pywapi.re                                  pywapi.xml_get_ns_yahoo_tag
pywapi.YAHOO_WEATHER_NS                    pywapi.get_weather_from_noaa               pywapi.sys                                 pywapi.yield_all_country_city_codes_yahoo

In [2]: pywapi.get_weather_from_yahoo?
Type:       function
String Form:<function get_weather_from_yahoo at 0x10daeb9b0>
File:       /Users/calvin/.virtualenvs/myweather/lib/python2.7/site-packages/pywapi.py
Definition: pywapi.get_weather_from_yahoo(location_id, units='metric')
Docstring:
Fetches weather report from Yahoo! Weather

Parameters:
  location_id: A five digit US zip code or location ID. To find your location ID,
  browse or search for your city from the Yahoo! Weather home page (http://weather.yahoo.com/)
  The weather ID is in the URL for the forecast page for that city. You can also get
  the location ID by entering your zip code on the home page. For example, if you
  search for Los Angeles on the Weather home page, the forecast page for that city
  is http://weather.yahoo.com/forecast/USCA0638.html. The location ID is USCA0638.

  units: type of units. 'metric' for metric and '' for non-metric
  Note that choosing metric units changes all the weather units to metric,
  for example, wind speed will be reported as kilometers per hour and
  barometric pressure as millibars.

Returns:
  weather_data: a dictionary of weather data that exists in XML feed.
  See http://developer.yahoo.com/weather/#channel

In [3]: pywapi.get_weather_from_yahoo('USCA0638')
Out[3]:
{'astronomy': {'sunrise': u'6:16 am', 'sunset': u'7:28 pm'},
 'atmosphere': {'humidity': u'67',
  'pressure': u'1013.7',
  'rising': u'1',
  'visibility': u'16.09'},
 'condition': {'code': u'33',
  'date': u'Sat, 20 Apr 2013 9:46 pm PDT',
  'temp': u'18',
  'text': u'Fair',
  'title': u'Conditions for Los Angeles, CA at 9:46 pm PDT'},
 'forecasts': [{'code': u'31',
   'date': u'20 Apr 2013',
   'day': u'Sat',
   'high': u'26',
   'low': u'15',
   'text': u'Clear'},
  {'code': u'32',
   'date': u'21 Apr 2013',
   'day': u'Sun',
   'high': u'26',
   'low': u'14',
   'text': u'Sunny'},
  {'code': u'34',
   'date': u'22 Apr 2013',
   'day': u'Mon',
   'high': u'22',
   'low': u'13',
   'text': u'Mostly Sunny'},
  {'code': u'30',
   'date': u'23 Apr 2013',
   'day': u'Tue',
   'high': u'21',
   'low': u'14',
   'text': u'Partly Cloudy'},
  {'code': u'30',
   'date': u'24 Apr 2013',
   'day': u'Wed',
   'high': u'19',
   'low': u'13',
   'text': u'Partly Cloudy'}],
 'geo': {'lat': u'34.05', 'long': u'-118.23'},
 'html_description': u'\n[![][5]][5]<br />\n<b>Current Conditions:</b><br />\nFair, 18 C<BR />\n<BR /><b>Forecast:</b><BR />\nSat - Clear. High: 26 Low: 15<br />\nSun - Sunny. High: 26 Low: 14<br />\nMon - Mostly Sunny. High: 22 Low: 13<br />\nTue - Partly Cloudy. High: 21 Low: 14<br />\nWed - Partly Cloudy. High: 19 Low: 13<br />\n<br />\n<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_c.html">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/>\n',
 'link': u'http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_c.html',
 'location': {'city': u'Los Angeles', 'country': u'US', 'region': u'CA'},
 'title': u'Yahoo! Weather - Los Angeles, CA',
 'units': {'distance': u'km',
  'pressure': u'mb',
  'speed': u'km/h',
  'temperature': u'C'},
 'wind': {'chill': u'18', 'direction': u'0', 'speed': u'0'}}
你可以使用Metwit。
如果您可以在客户端实现它们:200请求/天(基于ip的限制),则无需身份验证。全球覆盖,JSON和REST兼容。您可以免费注册额外的API调用,如果您仍然需要它来调用服务器端的API调用,那么基本的计划是相当便宜的

下面是jQuery中的一个小例子:使用我们的

全面披露:我拥有这段甜美的API。

你可以使用Metwit。
如果您可以在客户端实现它们:200请求/天(基于ip的限制),则无需身份验证。全球覆盖,JSON和REST兼容。您可以免费注册额外的API调用,如果您仍然需要它来调用服务器端的API调用,那么基本的计划是相当便宜的

下面是jQuery中的一个小例子:使用我们的


完整披露:我拥有这段可爱的API。

这里有大量示例-@CalvinCheng,pywapi是python内置的吗?如何获取天气图标?这里有大量示例-@CalvinCheng,pywapi是否内置于python中?如何获取天气图标?很好,让我试试这个。我还可以使用德国城市的德国邮政编码从yahoo获取数据吗?我安装了pywapi并将其放在settings.py中,但一旦我在my views.py中导入,就会显示错误,说pywapi未解析导入。有什么问题吗?
settings.py
views.py
pywapi
不是django应用程序。一旦您在
virtualenv
或您的全局站点包中安装了它(如果您没有使用
virtualenv
),它将在您的
视图.py中可用。(您不应该将其置于
settings.py
中,因为它不是django应用程序
)。如果您
views.py`无法导入它,则表示您的python路径设置错误。谢谢。但还有一个问题。我希望动态获取数据,而不是固定的城市名称。yahoo也可以这样做吗?很好,让我试试。我也可以使用德国城市的德国邮政编码从yahoo获取数据吗?我安装了pywapi并将其放入settings.py,但一旦我在my views.py中导入,就会显示一个错误,即pywapi未解析导入。有什么问题吗?
settings.py
views.py
pywapi
不是django应用程序。一旦您在
virtualenv
或您的全局站点包中安装了它(如果您没有使用
virtualenv
),它将在您的
视图.py中可用。(您不应该将其置于
settings.py
中,因为它不是django应用程序
)。如果您
views.py`无法导入它,则表示您的python路径设置错误。谢谢。但还有一个问题。我希望动态获取数据,而不是固定的城市名称。雅虎也可以这么做吗?哇,太酷了。它轻巧易用。谢谢你的提醒,可能是我选了这个版本哇,很酷。它轻巧易用。谢谢你的提醒,也许我正在使用这个版本