def call_whois(domain, ipobj): print domain whois = pywhois.whois(domain.domain_name) #save whois text to file f = open('%s/%s.%s.txt' % (settings.WHOIS_OUTPUT_DIR, domain.domain_name, DATE), 'w') f.write(whois.text) domain.registrar = '\n'.join(whois.registrar if hasattr(whois, 'registrar') else ' \n ') domain.registrar = domain.registrar.split('\n')[0] domain.whois_server_url = ' '.join(whois.whois_server if hasattr(whois, 'whois_server') else '') try: domain.domain_created_date = datetime.strptime(whois.creation_date[0],'%d-%b-%Y') domain.domain_updated_date = datetime.strptime(whois.updated_date[0],'%d-%b-%Y') domain.domain_expiration_date = datetime.strptime(whois.expiration_date[0],'%d-%b-%Y') except: pass for nameserver in whois.name_servers: dns_server = models.DomainNameServer(domain=domain, nameserver=nameserver, entity_active=True) dns_server.save() #for status in whois.status: # domain_status = models.DomainStatus(domain=domain, domain_status=status, entity_active=True) # domain_status.save() resolve_contact(whois.admin_contact if hasattr(whois,'admin_contact') else [], 'admin_contact', domain) resolve_contact(whois.tech_contact if hasattr(whois,'tech_contact') else [], 'tech_contact', domain)
def get_domain_name_registrar(self, host): """Get domain name registrar using python-whois.""" who = pywhois.whois(host) who.text whois_info = [who.registrar, who.referral_url] new_whois_info = ['N/A' if i == [] else i for i in whois_info] return new_whois_info
def get_whois(domain): i = { 'registered': False, 'expires': None } info = pywhois.whois(domain) if info.status: i['registered'] = True dformat = '%d-%b-%Y' if len(info.expiration_date[0]) > 11: dformat = '%a %b %d %H:%M:%S %Z %Y' i['expires'] = datetime.datetime.strptime(info.expiration_date[0], dformat) else: return info.text return i
def get_whois(domain): i = {'registered': False, 'expires': None} info = pywhois.whois(domain) if info.status: i['registered'] = True dformat = '%d-%b-%Y' if len(info.expiration_date[0]) > 11: dformat = '%a %b %d %H:%M:%S %Z %Y' i['expires'] = datetime.datetime.strptime(info.expiration_date[0], dformat) else: return info.text return i
def Command(pymyo, name, *args): for d in args: data = pywhois.whois(d) data_order = [ "domain_name", "registrant_name", "registrar", "registrar_url", "creation_date", "updated_date", "expiration_date", ] for d in data_order: try: pymyo.output("%s: %s" % (d.replace("_", " "), getattr(data, d, "")[0])) except: pymyo.output("%s: " % (d.replace("_", " ")))
def cmd_whois_domain(domain): """Simple whois client to check domain names. Example: \b $ habu.whois.domain portantier.com { "domain_name": "portantier.com", "registrar": "Amazon Registrar, Inc.", "whois_server": "whois.registrar.amazon.com", ... """ warnings.filterwarnings("ignore") data = whois.whois(domain) data = remove_duplicates(data) print(json.dumps(data, indent=4, default=str))
def __rawdata_set( self ) : domain_rec = "" self.__rawdata = pywhois.whois( self.__dname ) fl = False for i in self.__rawdata.text.split("\n"): if fl and not i.startswith("%") and i != "" and not i.startswith("created") \ and not i.startswith("status") and not i.startswith("dom-"): domain_rec += i + "\n" if i.startswith("% % .UA whois"): fl = True if fl and i == "": break if len(domain_rec) > 0: self.__data = domain_rec self.__valid = True else: self.__data = None self.__valid = False return self.__valid
def on_whois(self, bot, user, details): """WHOIS <domain> - Get info about a domain""" parts = details["splitmsg"] command = details["trigger"] if not parts: raise BadParams name = parts.pop(0) dom = pywhois.whois(name) try: emails = ", ".join(set([x.strip() for x in dom.emails])) ns = ", ".join(set([x.strip() for x in dom.name_servers])) reply = "Registrar: {0}, domain(s): {1}, email(s): [ {2} ], nameserver(s): [ {3} ]. ".format( dom.registrar[0].strip(), dom.domain_name[0].strip(), emails, ns) reply += "More info available at http://who.is/whois/{0}/".format(name) return reply except IndexError: return "The data for this domain is invalid."
def clean_desc(self): data = self.cleaned_data['desc'].strip() # url regexp regex = re.compile( r'^(https?://)?' # http:// or https:// r'(?P<domain>(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|[/?]\S+)$', re.IGNORECASE) match = regex.search(data) # if suggestion is url expect that for the domain name order if match: domain = match.group('domain') already_registered = False # first try open url try: urllib2.urlopen('http://%s' % domain) # if url not open try perform whois, may be domain already registered except: try: whois = pywhois.whois(domain) if whois.status: already_registered = True except PywhoisError: already_registered = False except: raise forms.ValidationError("sorry, but domain <b>%s</b> is invalid" % domain) # if url open hence domain name already registered else: already_registered = True if already_registered: raise forms.ValidationError("sorry, but domain <b>%s</b> has been already registered, you can suggest only not registered domains" % domain) return data
def whois(self, domain): try: w = pywhois.whois(domain) print "%s: registered" % domain except pywhois.parser.PywhoisError: print "%s: FREE" % domain
def default(self, domain): if domain.find('.') > -1: print pywhois.whois(domain).text else: for tld in self.TLDs: self.whois("%s%s" % (domain, tld))
def get_whois_information(domain_name): try: w = pywhois.whois(domain_name) except: w = " " return w
25 http://www.alidata.org 阿里集团数据平台 alidata.org 22 http://www.haidongji.com The Ji Village News 15 http://ditsing.github.com/ Blog of Ditsing 29 http://blog.devtang.com/ 唐巧的技术博客 14 http://www.0xsky.com Sky's Blog 14 http://meditic.com Howard's Startup Game @meditic 18 http://www.searchtb.com 搜索技术博客-淘宝 11 http://blog.ppcode.com/ 真水无香-清风是式,静水深流 35 http://blog.sina.com.cn/yinwang0 寂静之声 22 http://www.raychase.net 四火的唠叨 10 http://xiaoxins.com xiaoxins 8 http://blog.devep.net/virushuo/ demo@virushuo 11 http://www.codinglabs.org CodingLabs 10 http://kenwublog.com Ken Wu's Blog 10 http://www.cnblogs.com/haippy/ 博客园_Haippy 10 http://blog.oasisfeng.com Oasis Feng 75 http://blog.suchasplus.com/ suchasplus::blog 5 http://blog.sina.com.cn/u/2015038597 网络技术实验室 11 http://blog.linezing.com 量子恒道官方博客""".split("\n") from pywhois import whois from json import dumps for line in BLOG: line = line.strip() domain = line.split(" ", 3)[1] w = whois(domain) if hasattr(w, "emails"): emails = w.emails else: emails = [] print dumps(list(set(emails))), line
# This requires pywhois - https://github.com/unpluggd/pywhois/tree/master/pywhois import pywhois from itertools import product from string import ascii_lowercase length = 3 domains = [''.join(i) for i in product(ascii_lowercase, repeat = length)] print 'Available:' for d in domains: if not pywhois.whois(d+'.io'): print d + ".io is available print 'Done!'
def expiration(self): return pywhois.whois(self.url).expiration_date
def check_domain(domains,rq): for d in domains: w = whois(d) rq.put([w.domain_name,w.status,d])
import pywhois w = pywhois.whois('google.com') print(w.emails) print(w)
def admin_email(self): return pywhois.whois(self.url).emails
22 http://www.haidongji.com The Ji Village News 15 http://ditsing.github.com/ Blog of Ditsing 29 http://blog.devtang.com/ 唐巧的技术博客 14 http://www.0xsky.com Sky's Blog 14 http://meditic.com Howard's Startup Game @meditic 18 http://www.searchtb.com 搜索技术博客-淘宝 11 http://blog.ppcode.com/ 真水无香-清风是式,静水深流 35 http://blog.sina.com.cn/yinwang0 寂静之声 22 http://www.raychase.net 四火的唠叨 10 http://xiaoxins.com xiaoxins 8 http://blog.devep.net/virushuo/ demo@virushuo 11 http://www.codinglabs.org CodingLabs 10 http://kenwublog.com Ken Wu's Blog 10 http://www.cnblogs.com/haippy/ 博客园_Haippy 10 http://blog.oasisfeng.com Oasis Feng 75 http://blog.suchasplus.com/ suchasplus::blog 5 http://blog.sina.com.cn/u/2015038597 网络技术实验室 11 http://blog.linezing.com 量子恒道官方博客""".split("\n") from pywhois import whois from json import dumps for line in BLOG: line = line.strip() domain = line.split(" ",3)[1] w = whois(domain) if hasattr(w,"emails"): emails = w.emails else: emails = [] print dumps(list(set(emails))), line