.net support. Add test feature in parser.py.

This commit is contained in:
Larry Kim 2013-02-11 17:53:19 +09:00
parent c57b2726d8
commit 11e10b2e86
2 changed files with 12 additions and 3 deletions

View File

@ -70,11 +70,13 @@ class Parser(object):
except: except:
self.parseConf = self.parseDefaultConf.get("default") self.parseConf = self.parseDefaultConf.get("default")
def run(self): def run(self, TEST=False):
result = {} result = {}
for key in self.parseConf: for key in self.parseConf:
matches = re.findall(self.parseConf[key], self.text, re.MULTILINE) matches = re.findall(self.parseConf[key], self.text, re.MULTILINE)
if matches: if matches:
result.update({key: map(lambda x: x.strip(), matches)}) result.update({key: map(lambda x: x.strip(), matches)})
if TEST and not matches: print "No match for %s"%(key)
print result print result

View File

@ -1,11 +1,18 @@
server = { server = {
"host": "net.whois-servers.net", "host": "net.whois-servers.net",
"redirect": ".*Whois Server: (.*)", "redirect": "\s+Whois Server: (.*)",
} }
parse = { parse = {
"default": { "default": {
"NotFound": "No match for domain",
"DomainName": "Domain Name:\s+(.+)",
"Registrar": "Registrar:\s+(.+)",
"NameServer": "Name Server:\s+(.+)",
"Status": "Status:\s+(.+)",
"UpdatedDate": "Updated Date:\s+(.+)",
"CreationDate": "Creation Date:\s+(.+)",
"ExpirationDate": "Expiration Date:\s+(.+)",
}, },
"whois.dotname.co.kr": "whois.dotname.co.kr":
{ {