Prints the status of a link based on it's connection status
(self)
| 107 | print(self._to_json()) |
| 108 | |
| 109 | def showTable(self) -> None: |
| 110 | """ |
| 111 | Prints the status of a link based on it's connection status |
| 112 | """ |
| 113 | nodes = self.all_nodes_itr() |
| 114 | table_data = [] |
| 115 | |
| 116 | def insert(node, color_code): |
| 117 | status = str(node.data.status) |
| 118 | code = http.client.responses[node.data.status] |
| 119 | status_message = f'{status} {code}' |
| 120 | table_data.append([ |
| 121 | node.tag, |
| 122 | node.identifier, |
| 123 | color(status_message, color_code), |
| 124 | node.data.numbers, |
| 125 | node.data.emails, |
| 126 | node.data.classification, |
| 127 | ]) |
| 128 | |
| 129 | for node in nodes: |
| 130 | status_code = node.data.status |
| 131 | if status_code >= 200 and status_code < 300: |
| 132 | insert(node, 'green') |
| 133 | elif status_code >= 300 and status_code < 400: |
| 134 | insert(node, 'yellow') |
| 135 | else: |
| 136 | insert(node, 'red') |
| 137 | |
| 138 | headers = ["Title", "URL", "Status", "Phone Numbers", "Emails", "Category"] |
| 139 | table = tabulate(table_data, headers=headers) |
| 140 | print(table) |
| 141 | |
| 142 | |
| 143 | def parse_hostname(url: str) -> str: |