line = 1 #line number denotes the exact place where the exception is raised
try:
# Your configuration
USERNAME = "******"
PASSWORD = "******"
URI = "https://noc.enet.vn.ua/cgi-bin/power_check/power-vn.pl"
# specify the user agent
USER_AGENT = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
# verify the host. Skips verification if set to false
CERT_FILE = False
#diable the warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
urllib3.disable_warnings(urllib3.exceptions.HTTPError)
# Create a Session to contain you basic AUTH, it will also persist your cookies
line += 1#2
authed_session = requests.Session()
# Add your credentials
line += 1#3
authed_session.auth = (USERNAME, PASSWORD)
# Cert verification, will not verify on false
line += 1#4
authed_session.verify = CERT_FILE
line += 1#5
authed_session.headers.update({'User-Agent': USER_AGENT})
# Fetch the actual data
line += 1#6
fetched_data = authed_session.get(URI)
line += 1#7
soup = BS(fetched_data.content, "html.parser")
power = soup.find_all('tr')
for name in power:
n1 = str(name.text)
n2 = n1
character_map = {
ord('\n'):''
}
n2 = (n1.translate(character_map))
print(n2)