import requests
url = "https://open-weather13.p.rapidapi.com/city/San Diego"
headers = {
"X-RapidAPI-Key": "c0a73cc90fmshdc3d44c5a5834b9p18a538jsn06680b483b06",
"X-RapidAPI-Host": "open-weather13.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
print(response.text)
run = True
while run:
print("What city would you like to see the weather in? (type bye to close)")
city = input()
print(input)
if(input == "<bound method Kernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x12059eb30>>"):
print("Bye bye")
break
# Use input to pull city as json
import requests
url = "https://open-weather13.p.rapidapi.com/city/" + city
headers = {
"X-RapidAPI-Key": "c0a73cc90fmshdc3d44c5a5834b9p18a538jsn06680b483b06",
"X-RapidAPI-Host": "open-weather13.p.rapidapi.com"
}
response = requests.request("GET", url, headers=headers)
json = response.json()
# Use another while loop for they can see all categories
run2 = True
while run2:
category = input("What category would you like to see the weather in? (type bye to close)")
if(category == "bye"):
print("Bye bye")
break
try:
print("Ok, heres data for " + category + ": " + json[category])
except:
print("Not a valid category")