This is my script which is supposed to parse a list of domains (each seperated by returns) in a .txt file, separate them into individual domain names, send a request to a whois site with the domain name, check the response to see if it is available, and if it is, write it to a new file. so i get a list of only available names.
The problem? It's pretty simple i just dont know the language well enough, I dont know how to get the domain name in a string format so that the request to the whois site is like this :
http://whois.domaintools.com/google.com
Apparently the %s thing is not working.
Code:
#!/usr/bin/python
import urllib2, urllib
print "Domain Name Availability Scanner."
print "Enter the Location of the txt file containing your list of domains:"
path = raw_input("-->")
wordfile = open(path, "r")
words = wordfile.read().split("n")
words = map(lambda x: x.rstrip(), words)
wordfile.close()
for word in words:
req = urllib2.Request("http://whois.domaintools.com/%s") % (word)
source = urllib2.urlopen(req).read()
if "This domain name is not registered" in source:
f = open("success.txt", "a")
f.write("%s\n") % (word)
f.close()
break
error in terminal:
python domain.py
Domain Name Availability Scanner.
Enter the Location of the txt file containing your list of domains:
-->a.txt
Traceback (most recent call last):
File "domain.py", line 13, in <module>
req = urllib2.Request("http://whois.domaintools.com/%s") % (word)
TypeError: unsupported operand type(s) for %: 'instance' and 'str'