Python 域名转IP(可包含http、https)
生活随笔
收集整理的這篇文章主要介紹了
Python 域名转IP(可包含http、https)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
import socket
import tldextractdef get_ip(domain):ip = ''limit = 5domain = tldextract.extract(domain).fqdnwhile limit:try:ip = socket.gethostbyname(domain)breakexcept Exception as e:limit -= 1return ipprint(get_ip(www.baidu.com))
?
總結
以上是生活随笔為你收集整理的Python 域名转IP(可包含http、https)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 添加弹幕
- 下一篇: Treap与fhq_Treap模板(支持