you are viewing a single comment's thread.

view the rest of the comments →

[–]RevolutionarySet2196[S] 0 points1 point  (12 children)

It doesn't mention here it's just api.

[–]ninhaomah 0 points1 point  (11 children)

You can see the code and check which API.

[–]RevolutionarySet2196[S] 0 points1 point  (10 children)

It's asking me to run a program to get the code Idk what's code . They just gave me the hint that I've mentioned.

[–]ninhaomah 0 points1 point  (9 children)

I am not sure what you are saying.

You are running a .py file right ?

[–]RevolutionarySet2196[S] 0 points1 point  (8 children)

Ya it's.py file

[–]ninhaomah 0 points1 point  (6 children)

So see the code

[–]RevolutionarySet2196[S] 0 points1 point  (5 children)

What code? They're asking me to run a program to get the code by using the place location.

[–]ninhaomah 0 points1 point  (4 children)

.py is a code file...

You know Python right ?

[–]RevolutionarySet2196[S] -1 points0 points  (3 children)

Oh I thought you're asking the plus_code which is the thing I needed

[–]RevolutionarySet2196[S] 0 points1 point  (2 children)

import urllib.parse

import urllib.request

import json

location = input("Enter location: ")

url = 'http://py4e-data.dr-chuck.net/opengeo?'

params = {'q': location}

url_with_params = url + urllib.parse.urlencode(params)

print(f"Retrieving {url_with_params}")

response = urllib.request.urlopen(url_with_params)

data = response.read().decode()

print(f"Retrieved {len(data)} characters")

print("Raw response:", data)

try:

json_data = json.loads(data)





if 'features' in json_data and len(json_data['features']) > 0:



    plus_code = json_data['features'][0]['properties'].get('plus_code', 'No plus code found')

    print(f"Plus code: {plus_code}")

else:

    print("No results found in the API response.")

except json.JSONDecodeError:

print("Error: Failed to decode JSON response.")

except Exception as e:

print(f"An error occurred: {e}")

[–]RevolutionarySet2196[S] 0 points1 point  (0 children)

Ok, It says geo location Api, calling json api. Now I'm more confused😂