Advertisement
Eddy_S

Untitled

Jul 18th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from requests import get
  2. import requests
  3. import json
  4.  
  5. class location:
  6.     def __init__(self, query):
  7.         key = "key"
  8.         url = f"https://us1.locationiq.com/v1/search.php?key={key}&q={query}&format=json"
  9.         response = requests.get(url)
  10.         self.response = response
  11.     def get_latitude(self):
  12.         latitude = self.response.json()[0]["lat"]
  13.         print(latitude)
  14.     def get_longitude(self):
  15.         longitude = self.response.json()[0]["lon"]
  16.         print(longitude)
  17.  
  18. if __name__ == "__main__":
  19.     get_location = location(query)
  20.     get_location.get_latitude()
  21.     get_location.get_longitude()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement