()
| 10 | |
| 11 | |
| 12 | def checkInternetConnectivity(): |
| 13 | try: |
| 14 | url = argv[1] |
| 15 | print(url) |
| 16 | protocols = ["https://", "http://"] |
| 17 | if not any(x for x in protocols if x in url): |
| 18 | url = "https://" + url |
| 19 | print("URL:" + url) |
| 20 | except BaseException: |
| 21 | url = "https://google.com" |
| 22 | try: |
| 23 | urlopen(url, timeout=2) |
| 24 | print(f'Connection to "{url}" is working') |
| 25 | |
| 26 | except URLError as E: |
| 27 | print("Connection error:%s" % E.reason) |
| 28 | |
| 29 | |
| 30 | checkInternetConnectivity() |