Seeking for help as I would like to do a bulk whois lookup by reading a csv with domain names, and obtain the creation date of these domains and write it into a new csv.
import whois
infile = "domains.txt"
get domains from file
with open(infile, 'rb') as f: domains = [line.rstrip() for line in f if line.rstrip()]
for domain in domains: print (domain) record = whois.whois(domain)
# write each whois record to a file {domain}.txt
with open("%s.txt" % domain, 'wb') as f:
f.write(record.text)
The code above does not seems to work with error code shown below:
~\anaconda3\lib\site-packages\whois\__init__.py in whois(url, command, flags, executable)
31 def whois(url, command=False, flags=0, executable="whois"):
32 # clean domain to expose netloc
---> 33 ip_match = IPV4_OR_V6.match(url)
34 if ip_match:
35 domain = url
TypeError: cannot use a string pattern on a bytes-like object
`