通过一个接口 API,直接 GET 即可


import requests

def test_get_geo_for_ip():
    resp = requests.get(url = 'http://ip-api.com/json/%s' % ('3.115.236.139'))
    data = resp.json()
    print(data)