This commit is contained in:
Be
2024-03-03 12:45:49 +01:00
parent 27407898fc
commit 69655d18d3
4 changed files with 32 additions and 55 deletions

Binary file not shown.

28
pylib/whois.py Executable file
View File

@@ -0,0 +1,28 @@
import socket
def whois_query(query, get_field="netname"):
whois_server = "whois.ripe.net"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((whois_server, 43))
query = f"{query}\r\n"
s.send(query.encode())
response = ''
while True:
data = s.recv(4096)
try:
response += data.decode('utf-8')
except:
response += data.decode('latin-1')
if not data:
break
s.close()
for line in response.split('\n'):
if line.startswith(get_field + ':'):
return line.strip()
return None