from urllib.request import urlopen
def get_ip(self):
try:
return str(urlopen('http://159.75.41.235/').read())
except:
return False
print(get_ip())
Access to external network IP speed mainly depends on the server speed, this domestic than foreign those much faster
Return the sample
{"city_id":2140,"region":"China|0|Guangdong|Guangzhou|Guangdong Radio and Television","ip":"124.240.53.227"}
Read More:
- Python raspberry pie starts sending IP address to mailbox
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- How to Fix “HTTP error 403: forbidden” in Python 3. X
- Python: How to Disable InsecureRequestWarning error
- Python: How to Create an Automatic Recording Program
- Python: How to parses HTML, extracts data, and generates word documents
- How to Solve Python ImportError: cannot import name UnrewindableBodyError
- Python: How to get the size of the picture (byte/kb/mb)
- Python: How to Use try exception to Display Abnormal Error Information
- Python: How to Use os.path.join()
- How to Fix keyerror in Python dictionary lookup
- An introduction to sys modules in Python and how packages are imported and used
- Python: How to Set Line breaks and tabs for Strings
- How to Fix Python reading large local file memory error
- Python: How to Auto Add Watermark to PDF
- Python+OpenCV: How to Use Background Subtraction Methods
- Python: How to Encode the File (including HTML, TXT, Doc, etc.)
- Python: How to Solve multiprocessing module Error in Windows
- [Solved] uiautomatorviewer Error: Error obtaining UI hierarchy
- Python: How to Costomize the Background of PS