(uri: str)
| 67 | |
| 68 | |
| 69 | def get(uri: str): |
| 70 | try: |
| 71 | # Ignore the proxy settings in the environment. |
| 72 | proxy_handler = request.ProxyHandler({}) |
| 73 | https_handler = request.HTTPSHandler(context=ctx) |
| 74 | opener = request.build_opener(proxy_handler, https_handler) |
| 75 | |
| 76 | with opener.open(uri) as stream: |
| 77 | data = stream.read() |
| 78 | return data.decode("utf8") |
| 79 | except error.HTTPError as e: |
| 80 | return e.code |
| 81 | except Exception as e: |
| 82 | return str(e) |
| 83 | |
| 84 | |
| 85 | def detect_port(ip: str, port: int) -> bool: |