貌似没有现成的函数,可以自己简单实现一下:
import requests import json def get_my_ISP_address(): ip = ‘unkown‘ try: request_content = requests.get(‘http://httpbin.org/ip‘).text ip = json.loads(request_content)[‘origin‘] except Exception, e: print "Error for", e return ip if __name__ == ‘__main__‘: print get_my_ISP_address()
时间: 2024-10-08 18:51:33