Navigate the globe with Python's webpage geolocation lookup.

Geolocation API use case.


Very often for SEO professionals it is required to check websites' geographical data for certain domain and there is a very useful online service for web developers and SEO professionals on "WhoisXML API" that provides Domain & IP Data Intelligence for Greater Enterprise Security and RESTful APIs that we will use.

Using it's APIs you can perform many handy data requests, for example you can Websites' geolocation lookup data for a certain website/domail or IP address - don't forget to get your API KEY. You will obtain with one API call ready to use parsed list of IP geolocation details, Latitude and Longitude, time zone offset by UTC, domain registrar details, ASN information, etc.

Website geolocation lookup.
Website geolocation lookup meme.

Python Knowledge Base: Make coding great again.
- Updated: 2024-11-20 by Andrey BRATUS, Senior Data Analyst.




    This Python script below will use information from "WhoisXML API" and provide you a result in a JSON format without the need to use a web browser.
    Getting websites' geolocation data can be easily automated now !



  1. Python code to get Website geolocation data via API:


  2. 
    # Website IP Geolocation API USE
    
    import requests
    
    
    website = 'python-code.pro'
    
    APIKEY ='at_ZUVkrukr4UHznQq2j6dyv2VhFGWYV'
       
    
    GeoInfoURL = f'https://ip-geolocation.whoisxmlapi.com/api/v1?apiKey={APIKEY}&domain={website}'
    
    r = requests.get(GeoInfoURL)
    
    GeoInfo = r.json()
    
    print(f'Geolocation Info for {website} domain.\n')
    GeoInfo
    

  3. Website geolocation data output:


  4. 
    Geolocation Info for python-code.pro domain.
    
    {'ip': '89.108.102.163',
     'location': {'country': 'RU',
      'region': 'Moskva',
      'city': 'Spas',
      'lat': 55.83333,
      'lng': 37.4,
      'postalCode': '',
      'timezone': '+03:00',
      'geonameId': 489871},
     'domains': ['mail.python-code.pro',
      'python-code.pro',
      '89-108-102-163.cloudvps.regruhosting.ru',
      'leadfoundry.org',
      'www.python-code.pro'],
     'as': {'asn': 197695,
      'name': 'AS-REGRU',
      'route': '89.108.102.0/24',
      'domain': '',
      'type': ''},
     'isp': 'Domain names registrar REG.RU, Ltd',
     'connectionType': ''}
    




See also related topics: