开发者

trying to WHOIS a site within IRC

开发者 https://www.devze.com 2023-02-03 20:50 出处:网络
if data.find(\'!whois\') != -1: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((\"com.whois-servers.net\", 43))
      if data.find('!whois') != -1:
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.connect(("com.whois-servers.net", 43))
         s.send('www.msn.com' + "\r\n")
         response = ''
         while True:
              d = s.recv(4096)
              response += d
              if d == '':
   开发者_Go百科               break
         s.send('PRIVMSG ' + chan + " " + response + '\r\n')
         s.close()      

when I type !whois on the channel, it doesnt do anything, I'm probably doing this wrong. Any help will be appreciate it. Thanks.

Note: There's another socket already connected.


This snippet works in python3.1 with the whois site you mentioned.

#!/usr/bin/env python3

import socket

domain = "msn"

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("com.whois-servers.net", 43))
s.send(("%s\r\n" % domain).encode())
response = ""

while True:
  r = s.recv(4096).decode()
  response += r
  if r == "":
      break
print(response)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号