Gets the physical location corresponding to the specified IP address

Source: Internet
Author: User

# -*- coding: utf-8 -*-import requestsimport  jsondef get_physical_location (IP):    url =  ' http://ip.taobao.com/ Service/getipinfo.php?ip= '  + ip    ip_data = requests.get (URL). Text     ip_dict = json.loads (Ip_data)     if ip_dict.get (' Code '):         print (' You have entered an incorrect IP address format, please check it carefully. ')     else:        country = ip_dict.get (' data '). Get (' Country ')         region = ip_dict.get (' data '). Get (' Region ')         city = ip_dict.get (' data '). "Get (' City ')         print (country + region + city) get_physical _location (' 8.8.8.8 ') 


This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1661209

Gets the physical location corresponding to the specified IP address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.