Last active
August 9, 2017 15:42
-
-
Save mmattice/f9cc12f9a106319a8aaba06b6d9f4169 to your computer and use it in GitHub Desktop.
Cheap and easy advanced dns parser for namecheap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
html_doc=open('dns.html', 'r').read() | |
soup = BeautifulSoup(html_doc, 'html.parser') | |
table = soup.find('table', attrs={'class': 'advanced-dns'}) | |
rows = table.findAll('tr', attrs={'class': '[object Object]'}) | |
for row in rows: | |
cols = row.findAll('td') | |
rowtextl = [c.text.strip().replace('\n',' ') for c in cols] | |
removelist = (u'TTL Automatic', u'Remove Edit') | |
for r in removelist: | |
if r in rowtextl: | |
rowtextl.remove(r) | |
rowtextl[0] = rowtextl[0].replace(u'Type ', u'').replace(u' Record', u'') | |
rowtextl[1] = rowtextl[1].replace(u'Host ', u'') | |
striplist = (u'IP Address ', u'Target ', u'Nameserver ', u'Value ') | |
for s in striplist: | |
rowtextl[2] = rowtextl[2].replace(s, u'') | |
print rowtextl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment