Receiving results from a different IP address than one input via url requests

116 Views Asked by At

Can't understand why I'm getting this output:

Enter IP list filename: nearmeips.txt 216.128.74.178 **** <Response [200]> {'country_code': 'US', 'country_name': 'United States', 'city': 'Antioch', 'postal': '37013', 'latitude': 36.0595, 'longitude': -86.6592, 'IPv4': '172.58.146.151', 'state': 'Tennessee'}

When 216.128.74.178 is the top of my list of nearmeips.

172.58.146.178 was never passed by me to the site. Here is the code.

 
import os
import files                          
import sys                            
import re                             
import time                           
import requests                       
import json                                                                   

file_name = input("Enter IP list filename: ")
with open(file_name, 'r') as file:          
    ip_add = file.readline()    
    print(ip_add,"****")                                                                   
    request_url = 'https://geolocation-db.com/jsonp/' + ip_add    
    response = requests.get(request_url)  
    print(response)  
    result = response.content.decode()   
    # Clean the returned string so it just contains the dictionary data for the IP address 
    result = result.split("(")[1].strip(")")  
    # Convert this data into a dictionary          
    result  = json.loads(result)    
    print(result)

I'm using termux in a non-root phone is the only thing I can think of, but I'm new to coding so I'm stumped.

0

There are 0 best solutions below