[Tutor] Checking for custom error codes

wormwood_3 wormwood_3 at yahoo.com
Wed Aug 8 03:22:04 CEST 2007


>>Examining rwhois.py reveals

>>raise 'NoSuchDomain'

>>>which is a string exception. Which should work even tho deprecated.

>>>When you say it did not work what is the evidence?


-- 
Bob Gailer
510-978-4454 Oakland, CA
919-636-4239 Chapel Hill, NC
_______________________________________
I did speak too soon on this. When I run the script using the code at the end, I get:

rwhois.py:327: DeprecationWarning: raising a string exception is deprecated
  raise 'NoSuchDomain', self.domain

===================
    def lookup(self):
        """
        Looks up each word in our list with whois
        """
        """
        Using rwhois, which is either broken or lacks most data:
        """
        from rwhois import WhoisRecord
        who = WhoisRecord()
        self.totalchecked = 0
        self.availdomains = []
        for potdomain in self.potdomains:
            try: 
                who.whois(potdomain)
                self.availdomains.append(potdomain)
            except 'NoSuchDomain':
                pass
            self.totalchecked+=1
    def printresults(self):
        """
        Prints the ones that do not seem to be taken, with some stats.
        """
        print "Results are in! "
        print "%s total words checked, as .com and .net domains." % (self.totalchecked / 2)
        print "----------------------"
        print "Domains that seem to be available: \n"
        for availdomain in self.availdomains:
            print availdomain 
        print "\n"
        print "----------------------"
====================

Then, I get back items in the list such as:

Domains that seem to be available: 

AA.com
AARP.com
AARP.net

I confirmed in spotchecking that some of these are taken, such as with whois -H AARP.com:
   Domain Name: AARP.COM
   Registrar: NETWORK SOLUTIONS, LLC.
   Whois Server: whois.networksolutions.com

This may, however, be something else wrong with my code, or the rwhois module, not the try, except check.






More information about the Tutor mailing list