Created
July 9, 2021 02:27
-
-
Save h1code2/0edbab500f4fb73e26981e5c68c5214a to your computer and use it in GitHub Desktop.
Revisions
-
h1code2 created this gist
Jul 9, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/30 16:13 # @Author : h1code2 # @File : code.py # @Software: PyCharm # import module from geopy.geocoders import Nominatim # initialize Nominatim API geo_locator = Nominatim(user_agent="GoSpider") # Latitude & Longitude input Latitude = "25.124398793756" Longitude = "62.326154919175" location = geo_locator.reverse(Latitude + "," + Longitude, language="en") address = location.raw['address'] # traverse the data city = address.get('city', '') state = address.get('state', '') country = address.get('country', '') code = address.get('country_code') zipcode = address.get('postcode') print('City : ', city) print('State : ', state) print('Country : ', country) print('Zip Code : ', zipcode)