본문 바로가기

개발자 모드/파이썬(python)

파이썬 외부 IP 정보 얻는법

728x90
import requests
import re

req = requests.get("http://ipconfig.kr")
out_addr = re.search(r'IP Address : (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', req.text)[1]
print(out_addr)

 

 

 

728x90