Exemplo n.º 1
0
def main():
    """ Get geo id for geo location, and request current weather condition.
    Retrieve current temperature and location local time.
    """

    degree = u"\N{DEGREE SIGN}"

    # Geo request
    geo_url = wetteronline.request_url(KEY, UID, lat=LAT, lon=LON)
    wog = wetteronline.load_wetteronline(geo_url)
    print('Geo data: {}'.format(wog.json))
    gid = wog.gid()
    location = wog._wetteronline_data('locationName')

    # Weather request
    weather_url = wetteronline.request_url(KEY, UID, gid=gid)
    wow = wetteronline.load_wetteronline(weather_url)
    date_time = wow._wetteronline_data('local_date', gid=gid)
    temperature = wow._wetteronline_data('tt_C', gid=gid)
    fahrenheit = convert_c2f(temperature)

    print('Date Time: {}'.format(date_time))
    print('Weather data response: {}'.format(wow.json))
    print(u'{}: Current Temperature {}C{}/{:.2f}F'.format(location, temperature,
                                                      degree, fahrenheit))
Exemplo n.º 2
0
def build_request_url(lat, lon):
    """Create geo api url"""

    return wetteronline.request_url(KEY, UID, lat=lat, lon=lon)