Create a subclass to find the files within the authenticated HTML page.
| 29 | |
| 30 | |
| 31 | class MyHTMLParser(HTMLParser): |
| 32 | """ |
| 33 | Create a subclass to find the files within the authenticated HTML page. |
| 34 | """ |
| 35 | |
| 36 | any_url = "" |
| 37 | a_url = "" |
| 38 | aaaa_url = "" |
| 39 | mx_url = "" |
| 40 | cname_url = "" |
| 41 | txt_url = "" |
| 42 | txt_mx_dmarc = "" |
| 43 | txt_mx_mta_sts = "" |
| 44 | rdns_url = "" |
| 45 | base_url = "" |
| 46 | |
| 47 | def set_base_location(self, base_location): |
| 48 | self.base_url = base_location |
| 49 | |
| 50 | def handle_starttag(self, tag, attrs): |
| 51 | logger = logging.getLogger(__name__) |
| 52 | if tag == "a": |
| 53 | for attr in attrs: |
| 54 | if ( |
| 55 | self.any_url == "" |
| 56 | and attr[0] == "href" |
| 57 | and attr[1].endswith("fdns_any.json.gz") |
| 58 | ): |
| 59 | logger.info(attr[1]) |
| 60 | self.any_url = self.base_url + attr[1] |
| 61 | elif ( |
| 62 | self.a_url == "" |
| 63 | and attr[0] == "href" |
| 64 | and attr[1].endswith("fdns_a.json.gz") |
| 65 | ): |
| 66 | logger.info(attr[1]) |
| 67 | self.a_url = self.base_url + attr[1] |
| 68 | elif ( |
| 69 | self.aaaa_url == "" |
| 70 | and attr[0] == "href" |
| 71 | and attr[1].endswith("fdns_aaaa.json.gz") |
| 72 | ): |
| 73 | logger.info(attr[1]) |
| 74 | self.aaaa_url = self.base_url + attr[1] |
| 75 | elif ( |
| 76 | self.mx_url == "" |
| 77 | and attr[0] == "href" |
| 78 | and attr[1].endswith("fdns_mx.json.gz") |
| 79 | ): |
| 80 | logger.info(attr[1]) |
| 81 | self.mx_url = self.base_url + attr[1] |
| 82 | elif ( |
| 83 | self.cname_url == "" |
| 84 | and attr[0] == "href" |
| 85 | and attr[1].endswith("fdns_cname.json.gz") |
| 86 | ): |
| 87 | logger.info(attr[1]) |
| 88 | self.cname_url = self.base_url + attr[1] |