/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
internet_connection_py3.py
30 строк
778 B
slowy07
refactor: clean code
30 янв 2022, 04:33
30 янв 2022, 04:33
f0af0c4
Код
Авторство
О чём код?
from __future__ import print_function import os import urllib.request from selenium import webdriver print("Testing Internet Connection") print() try: urllib.request.urlopen( "http://google.com", timeout=2 ) # Tests if connection is up and running print("Internet is working fine!") print() question = input("Do you want to open a website? (Y/N): ") if question == "Y": print() search = input("Input website to open (http://website.com) : ") else: os._exit(0) except urllib.error.URLError: print("No internet connection!") # Output if no connection browser = webdriver.Firefox() browser.get(search) os.system("cls") # os.system('clear') if Linux print("[+] Website " + search + " opened!") browser.close()