I have a list of a bunch of IP addresses. I am wondering if it is possible to use python to determine the country name of the IP addresses by extracting the information from this website (http://www.whatip.com/ip-lookup). Please see the screenshot below. e.g: IPlist = ["100.43.90.10","125.7.8.9.9"]
Here is my code: I understand i could change the search url by concatenating the actual url with the suffix (=my IP address). And I want to get "United States"
Here is the screenshot of where "United States" is located:
import urllib.request
with urllib.request.urlopen('http://www.whatip.com/ip/100.43.90.10') as response:
html = response.read()
print (html)
text = html.decode()
start = text.find("<td>Country:</td>")
I checked there is only one "Country" in the source code. I understand that I need to find the index of "Country", and then print out "United States" but I got stuck. Anyone plz tell me how to do it? Many thanks!!